ramifice 0.4.4__py3-none-any.whl → 0.4.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ramifice/commons/tools.py +11 -12
- ramifice/paladins/tools.py +2 -1
- {ramifice-0.4.4.dist-info → ramifice-0.4.5.dist-info}/METADATA +9 -3
- {ramifice-0.4.4.dist-info → ramifice-0.4.5.dist-info}/RECORD +6 -6
- {ramifice-0.4.4.dist-info → ramifice-0.4.5.dist-info}/WHEEL +0 -0
- {ramifice-0.4.4.dist-info → ramifice-0.4.5.dist-info}/licenses/LICENSE +0 -0
ramifice/commons/tools.py
CHANGED
@@ -23,13 +23,12 @@ def from_mongo_doc(
|
|
23
23
|
mongo_doc: dict[str, Any],
|
24
24
|
) -> Any:
|
25
25
|
"""Create object instance from Mongo document."""
|
26
|
-
obj = cls_model()
|
26
|
+
obj: Any = cls_model()
|
27
|
+
lang: str = translations.CURRENT_LOCALE
|
27
28
|
for name, data in mongo_doc.items():
|
28
29
|
field = obj.__dict__[name]
|
29
|
-
if "TextField"
|
30
|
-
field.value = (
|
31
|
-
data[translations.CURRENT_LOCALE] if isinstance(field.value, dict) else None
|
32
|
-
)
|
30
|
+
if field.field_type == "TextField":
|
31
|
+
field.value = data.get(lang, "") if data is not None else None
|
33
32
|
elif field.group == "pass":
|
34
33
|
field.value = None
|
35
34
|
else:
|
@@ -50,28 +49,28 @@ def mongo_doc_to_raw_doc(
|
|
50
49
|
datetime to str
|
51
50
|
"""
|
52
51
|
doc: dict[str, Any] = {}
|
53
|
-
|
52
|
+
lang: str = translations.CURRENT_LOCALE
|
54
53
|
for f_name, t_name in field_name_and_type.items():
|
55
54
|
value = mongo_doc[f_name]
|
56
55
|
if value is not None:
|
57
|
-
if "TextField"
|
58
|
-
value = value
|
56
|
+
if t_name == "TextField":
|
57
|
+
value = value.get(lang, "") if value is not None else None
|
59
58
|
elif "Date" in t_name:
|
60
59
|
if "Time" in t_name:
|
61
60
|
value = format_datetime(
|
62
61
|
datetime=value,
|
63
62
|
format="short",
|
64
|
-
locale=
|
63
|
+
locale=lang,
|
65
64
|
)
|
66
65
|
else:
|
67
66
|
value = format_date(
|
68
67
|
date=value.date(),
|
69
68
|
format="short",
|
70
|
-
locale=
|
69
|
+
locale=lang,
|
71
70
|
)
|
72
|
-
elif "IDField"
|
71
|
+
elif t_name == "IDField":
|
73
72
|
value = str(value)
|
74
|
-
elif "PasswordField"
|
73
|
+
elif t_name == "PasswordField":
|
75
74
|
value = None
|
76
75
|
doc[f_name] = value
|
77
76
|
return doc
|
ramifice/paladins/tools.py
CHANGED
@@ -14,10 +14,11 @@ def ignored_fields_to_none(inst_model: Any) -> None:
|
|
14
14
|
|
15
15
|
def refresh_from_mongo_doc(inst_model: Any, mongo_doc: dict[str, Any]) -> None:
|
16
16
|
"""Update object instance from Mongo document."""
|
17
|
+
lang: str = translations.CURRENT_LOCALE
|
17
18
|
for name, data in mongo_doc.items():
|
18
19
|
field = inst_model.__dict__[name]
|
19
20
|
if field.field_type == "TextField":
|
20
|
-
field.value = data
|
21
|
+
field.value = data.get(lang, "") if data is not None else None
|
21
22
|
elif field.group == "pass":
|
22
23
|
field.value = None
|
23
24
|
else:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ramifice
|
3
|
-
Version: 0.4.
|
3
|
+
Version: 0.4.5
|
4
4
|
Summary: ORM-like API MongoDB for Python language.
|
5
5
|
Project-URL: Homepage, https://github.com/kebasyaty/ramifice
|
6
6
|
Project-URL: Documentation, https://kebasyaty.github.io/ramifice/
|
@@ -243,8 +243,14 @@ async def main():
|
|
243
243
|
user.print_err()
|
244
244
|
|
245
245
|
print("User details:")
|
246
|
-
user_details = await User.find_one_to_raw_doc(
|
247
|
-
|
246
|
+
user_details = await User.find_one_to_raw_doc(
|
247
|
+
# {"_id": user.id.value}
|
248
|
+
{f"username.{translations.CURRENT_LOCALE}": user.username.value}
|
249
|
+
)
|
250
|
+
if user_details is not None:
|
251
|
+
pprint.pprint(user_details)
|
252
|
+
else:
|
253
|
+
print("No User!")
|
248
254
|
|
249
255
|
# Remove User.
|
250
256
|
await user.delete(remove_files=False)
|
@@ -5,7 +5,7 @@ ramifice/commons/general.py,sha256=dy2GTpekLyshrNG68XV2dxNgwsS4QODtIcG-c6Xvalw,4
|
|
5
5
|
ramifice/commons/indexes.py,sha256=hAcWKZ9MMgLbRtoQ6Af0b8r-PY0dbEYmMBl8z_d1DRo,3646
|
6
6
|
ramifice/commons/many.py,sha256=KGt7licVJmLADvyPtH7-GbXHig-EnGFbnk7QKu3mfvQ,8214
|
7
7
|
ramifice/commons/one.py,sha256=h9R-Ev-7h-xln4lp4SMJIIU9Cf9acqwjj4YYaML6uFg,5832
|
8
|
-
ramifice/commons/tools.py,sha256=
|
8
|
+
ramifice/commons/tools.py,sha256=zR-mmqqsfSWKF0lws1qMvCh-sauJa8pHX5GNJZdAjMI,2341
|
9
9
|
ramifice/commons/unit_manager.py,sha256=IkWqXu1PHHal0aGfx6zme81iXPeygxPqEWO-u_8RXoI,4356
|
10
10
|
ramifice/fields/__init__.py,sha256=yRfX7Tvpuh27Ggcx5u9e1RRYK7Wu59EVJYxxetmuP1w,1290
|
11
11
|
ramifice/fields/bool_field.py,sha256=WWubSwsFJZu8b3MviDd2zXnNYOQaYw8toklFNSTVFLA,2072
|
@@ -53,7 +53,7 @@ ramifice/paladins/delete.py,sha256=tw50E98D5eFZ7gHGnh_8ztUB1LeTeWWKZvIcQqlgbF8,3
|
|
53
53
|
ramifice/paladins/password.py,sha256=w1XWh3bsncH1VTVjCLxyKI2waxMvltwcsPWW3V9Ib84,3027
|
54
54
|
ramifice/paladins/refrash.py,sha256=fw-9x_NKGzreipBt_F9KF6FTsYm9hSzfq4ubi1FHYrQ,1065
|
55
55
|
ramifice/paladins/save.py,sha256=EG0_v-imCQPax2pJIAXPoQcSL99g8abY2EeGJMvXBW4,3864
|
56
|
-
ramifice/paladins/tools.py,sha256=
|
56
|
+
ramifice/paladins/tools.py,sha256=QxxwZILyBLcAiDUN48KE99c_cHVjG-VYilEsIinRhEU,2641
|
57
57
|
ramifice/paladins/validation.py,sha256=gcEJXIEPu1g7Z54vl14YTs5rCmxOEYsgQH1usFfyy7k,1730
|
58
58
|
ramifice/paladins/groups/__init__.py,sha256=hpqmWLsYAMvZHAbmMXluQSqLhkHOSTUAgLHyTM1LTYI,472
|
59
59
|
ramifice/paladins/groups/bool_group.py,sha256=oJc9mw9KGrnK_Pj7uXixYYQAJphcXLr_xSQv3PMUlcU,792
|
@@ -79,7 +79,7 @@ ramifice/utils/mixins/add_valid.py,sha256=TLOObedzXNA9eCylfAVbVCqIKE5sV-P5AdIN7a
|
|
79
79
|
ramifice/utils/mixins/hooks.py,sha256=33jvJRhfnJeL2Hd_YFXk3M_7wjqHaByU2wRjKyboL6s,914
|
80
80
|
ramifice/utils/mixins/indexing.py,sha256=Z0427HoaVRyNmSNN8Fx0mSICgAKV-gDdu3iR5qYUEbs,329
|
81
81
|
ramifice/utils/mixins/json_converter.py,sha256=WhigXyDAV-FfILaZuwvRFRIk0D90Rv3dG5t-mv5fVyc,1107
|
82
|
-
ramifice-0.4.
|
83
|
-
ramifice-0.4.
|
84
|
-
ramifice-0.4.
|
85
|
-
ramifice-0.4.
|
82
|
+
ramifice-0.4.5.dist-info/METADATA,sha256=2gwEZsJJmFhhFAayDTWsB1kIKwWNmeadZVMt-4Fgwyc,21369
|
83
|
+
ramifice-0.4.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
84
|
+
ramifice-0.4.5.dist-info/licenses/LICENSE,sha256=LrEL0aTZx90HDwFUQCJutORiDjJL9AnuVvCtspXIqt4,1095
|
85
|
+
ramifice-0.4.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|