ramifice 0.4.2__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.
@@ -99,6 +99,8 @@ class CheckMixin(
99
99
  err_msg = error_map.get(field_name)
100
100
  if bool(err_msg):
101
101
  field_data.errors.append(err_msg)
102
+ if not params["is_error_symptom"]:
103
+ params["is_error_symptom"] = True
102
104
  # Checking the fields by groups.
103
105
  if not field_data.ignored:
104
106
  group = field_data.group
@@ -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] if params["is_update"] else {}
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, text in value.items():
94
- mult_lang_text[lang] = text
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
@@ -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 and field_data.name != "_id":
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" == field.field_type:
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:
@@ -68,7 +68,7 @@ async def apply_fixture(
68
68
  print(colored("\nFIXTURE:", "red", attrs=["bold"]))
69
69
  print(colored(fixture_path, "blue", attrs=["bold"]))
70
70
  inst_model.print_err()
71
- raise PanicError("!!!")
71
+ raise PanicError("Error: Fixtures")
72
72
  # Get data for document.
73
73
  checked_data: dict[str, Any] = result_check["data"]
74
74
  # Add date and time.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ramifice
3
- Version: 0.4.2
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():
@@ -48,12 +48,12 @@ ramifice/models/decorator.py,sha256=jOEn-0v0m_tM7mow45-tM-8LADUmwlG2DWZsEuC9S_w,
48
48
  ramifice/models/model.py,sha256=ZvgIbcuSXuAkBl_FofOZXGwWMwlqKB-PwTMyXiqK-Fo,6610
49
49
  ramifice/models/pseudo.py,sha256=PhLQM4zXdaOtTSmNFzwN4twlUmdvA1D_-YOMJtaOIwM,6754
50
50
  ramifice/paladins/__init__.py,sha256=PIP3AXI2KBRXNcLJUF0d7ygJ7VLOAxlhb4HRKQ9MGYY,516
51
- ramifice/paladins/check.py,sha256=SdDC9cE4I_Pt9L9NTatEzNYtwpcCIy03yCJqi1O6qM8,6796
51
+ ramifice/paladins/check.py,sha256=9VQmr3GXaGitMQl-3KOZP-2_xYC7JG_jDLM62iKx1b4,6903
52
52
  ramifice/paladins/delete.py,sha256=tw50E98D5eFZ7gHGnh_8ztUB1LeTeWWKZvIcQqlgbF8,3352
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=SCmESo8isvcy0yk43Rj1J5BZ1xSZbNV1KLhhBrzfezY,2687
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,10 +65,10 @@ 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=67gk-vEoZImifCqIzWYexc0Yj2__srFAUqmOHRhBgOk,4005
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
- ramifice/utils/fixtures.py,sha256=NtxOnZslYJb4yvRpZbs3ckugmTwHQFS_9iCt2zddOC0,3102
71
+ ramifice/utils/fixtures.py,sha256=Krl31nNShEg6A15Q8WRDqIai0bPyaJuK8jEGt5ySzao,3114
72
72
  ramifice/utils/globals.py,sha256=uR20um3Qg_1SG1t7WyWbpq8kQD-9Mslyr_c1yh5Hw9w,1751
73
73
  ramifice/utils/migration.py,sha256=LON53a8oBpjc9ox-FzqBEGsAWnqW8t-CWBkRC7BbwxI,11022
74
74
  ramifice/utils/tools.py,sha256=sOKzwnvf6vdTNf9r6PKAdw6aB4undat2Z8tzS3M1GnQ,2733
@@ -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.2.dist-info/METADATA,sha256=ZJlFn29k4RDuT4iyHoqJQl4VTx4otqyDr27fb6I3KKA,21049
83
- ramifice-0.4.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
84
- ramifice-0.4.2.dist-info/licenses/LICENSE,sha256=LrEL0aTZx90HDwFUQCJutORiDjJL9AnuVvCtspXIqt4,1095
85
- ramifice-0.4.2.dist-info/RECORD,,
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,,