ramifice 0.4.3__py3-none-any.whl → 0.4.4__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/paladins/groups/text_group.py +9 -3
- ramifice/paladins/tools.py +3 -5
- {ramifice-0.4.3.dist-info → ramifice-0.4.4.dist-info}/METADATA +7 -2
- {ramifice-0.4.3.dist-info → ramifice-0.4.4.dist-info}/RECORD +6 -6
- {ramifice-0.4.3.dist-info → ramifice-0.4.4.dist-info}/WHEEL +0 -0
- {ramifice-0.4.3.dist-info → ramifice-0.4.4.dist-info}/licenses/LICENSE +0 -0
@@ -87,11 +87,17 @@ class TextGroupMixin:
|
|
87
87
|
if params["is_save"]:
|
88
88
|
if is_text_field:
|
89
89
|
mult_lang_text: dict[str, str] = (
|
90
|
-
params["curr_doc"][field_name]
|
90
|
+
params["curr_doc"][field_name]
|
91
|
+
if params["is_update"]
|
92
|
+
else (
|
93
|
+
{lang: value for lang in translations.LANGUAGES}
|
94
|
+
if isinstance(value, str)
|
95
|
+
else {lang: value.get(lang, "") for lang in translations.LANGUAGES}
|
96
|
+
)
|
91
97
|
)
|
92
98
|
if isinstance(value, dict):
|
93
|
-
for lang
|
94
|
-
mult_lang_text[lang] =
|
99
|
+
for lang in translations.LANGUAGES:
|
100
|
+
mult_lang_text[lang] = value.get(lang, "")
|
95
101
|
else:
|
96
102
|
mult_lang_text[translations.CURRENT_LOCALE] = value
|
97
103
|
value = mult_lang_text
|
ramifice/paladins/tools.py
CHANGED
@@ -8,7 +8,7 @@ from ..utils import errors, translations
|
|
8
8
|
def ignored_fields_to_none(inst_model: Any) -> None:
|
9
9
|
"""Reset the values of ignored fields to None."""
|
10
10
|
for _, field_data in inst_model.__dict__.items():
|
11
|
-
if not callable(field_data) and field_data.ignored
|
11
|
+
if not callable(field_data) and field_data.ignored:
|
12
12
|
field_data.value = None
|
13
13
|
|
14
14
|
|
@@ -16,10 +16,8 @@ def refresh_from_mongo_doc(inst_model: Any, mongo_doc: dict[str, Any]) -> None:
|
|
16
16
|
"""Update object instance from Mongo document."""
|
17
17
|
for name, data in mongo_doc.items():
|
18
18
|
field = inst_model.__dict__[name]
|
19
|
-
if "TextField"
|
20
|
-
field.value = (
|
21
|
-
data[translations.CURRENT_LOCALE] if isinstance(field.value, dict) else None
|
22
|
-
)
|
19
|
+
if field.field_type == "TextField":
|
20
|
+
field.value = data[translations.CURRENT_LOCALE] if isinstance(data, dict) else None
|
23
21
|
elif field.group == "pass":
|
24
22
|
field.value = None
|
25
23
|
else:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ramifice
|
3
|
-
Version: 0.4.
|
3
|
+
Version: 0.4.4
|
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/
|
@@ -136,6 +136,7 @@ from datetime import datetime
|
|
136
136
|
from pymongo import AsyncMongoClient
|
137
137
|
from ramifice import model, translations, migration
|
138
138
|
from ramifice.fields import (
|
139
|
+
BooleanField,
|
139
140
|
DateField,
|
140
141
|
EmailField,
|
141
142
|
FileField,
|
@@ -193,13 +194,16 @@ class User:
|
|
193
194
|
# If true, the value of this field is not saved in the database.
|
194
195
|
ignored=True,
|
195
196
|
)
|
197
|
+
self.is_admin = BooleanField(
|
198
|
+
label=gettext("Is Administrator?"),
|
199
|
+
)
|
196
200
|
|
197
201
|
# Optional method.
|
198
202
|
async def add_validation(self) -> dict[str, str]:
|
199
203
|
"""Additional validation of fields."""
|
200
204
|
gettext = translations.gettext
|
201
205
|
error_map: dict[str, str] = {}
|
202
|
-
if self.password != self.сonfirm_password:
|
206
|
+
if self.password.value != self.сonfirm_password.value:
|
203
207
|
error_map["password"] = gettext("Passwords do not match!")
|
204
208
|
return error_map
|
205
209
|
|
@@ -226,6 +230,7 @@ async def main():
|
|
226
230
|
user.birthday.value = datetime(2000, 1, 25)
|
227
231
|
user.password.value = "12345678"
|
228
232
|
user.сonfirm_password.value = "12345678"
|
233
|
+
user.is_admin.value = True
|
229
234
|
|
230
235
|
# Create User.
|
231
236
|
if not await user.save():
|
@@ -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=7F66koM5In1skViEWExBbSxuGrKh1k-RqaawuRFuEj4,2617
|
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
|
@@ -65,7 +65,7 @@ ramifice/paladins/groups/img_group.py,sha256=RoD_QnW0F0DAzrGQmRi8jMZnWy2IomlFn6A
|
|
65
65
|
ramifice/paladins/groups/num_group.py,sha256=6jT7nfIiVoQTlI2UdkcQOlHIDYjllFqSH7Nb87uJgzg,2274
|
66
66
|
ramifice/paladins/groups/pass_group.py,sha256=YU5a-NwohEutoEx2N5JmGfg8uPiYiW0XJ8XYsOih6eA,1859
|
67
67
|
ramifice/paladins/groups/slug_group.py,sha256=joBB5litljbv2h5JKEMzF71s_DKMWH6nzgThLiLZx2E,2307
|
68
|
-
ramifice/paladins/groups/text_group.py,sha256=
|
68
|
+
ramifice/paladins/groups/text_group.py,sha256=rUWNaAPkTMMlRf6A-6nQAa4HCj6NBTjPKIYaEKSOUL4,4305
|
69
69
|
ramifice/utils/__init__.py,sha256=xixHoOX4ja5jIUZemem1qn4k4aonv3G3Q76azQK_pkU,43
|
70
70
|
ramifice/utils/errors.py,sha256=iuhq7fzpUmsOyeXeg2fJjta8yAuqlXLKsZVMpfUhtHE,1901
|
71
71
|
ramifice/utils/fixtures.py,sha256=Krl31nNShEg6A15Q8WRDqIai0bPyaJuK8jEGt5ySzao,3114
|
@@ -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.4.dist-info/METADATA,sha256=6oAjlZe-e-NlTj03piyFrubVkp7dvH8uzkHOf1qeUgo,21207
|
83
|
+
ramifice-0.4.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
84
|
+
ramifice-0.4.4.dist-info/licenses/LICENSE,sha256=LrEL0aTZx90HDwFUQCJutORiDjJL9AnuVvCtspXIqt4,1095
|
85
|
+
ramifice-0.4.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|