ramifice 0.3.22__py3-none-any.whl → 0.3.24__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/decorators.py CHANGED
@@ -126,8 +126,9 @@ def caching(cls: Any, service_name: str, is_migrate_model: bool) -> dict[str, An
126
126
 
127
127
  raw_model = cls()
128
128
  raw_model.fields()
129
- default_fields: dict[str, Any] = {"_id": IDField()}
129
+ default_fields: dict[str, Any] = {}
130
130
  if is_migrate_model:
131
+ default_fields["_id"] = IDField()
131
132
  default_fields["created_at"] = DateTimeField()
132
133
  default_fields["updated_at"] = DateTimeField()
133
134
  fields = {**raw_model.__dict__, **default_fields}
@@ -46,6 +46,7 @@ class CheckMixin(
46
46
  """
47
47
  cls_model = self.__class__
48
48
  is_migrate_model: bool = cls_model.META["is_migrate_model"] # type: ignore[attr-defined]
49
+
49
50
  if not is_migrate_model and is_save:
50
51
  msg = (
51
52
  f"Model: `{self.full_model_name()}` > " # type: ignore[attr-defined]
@@ -53,16 +54,19 @@ class CheckMixin(
53
54
  + "For a non -migrating Model, the `is_save` parameter must be equal to` False` !"
54
55
  )
55
56
  raise PanicError(msg)
56
- # Get the document ID.
57
- doc_id: ObjectId | None = self._id.value # type: ignore[attr-defined]
58
- # Does the document exist in the database?
59
- is_update: bool = doc_id is not None
60
- # Create an identifier for a new document.
61
- if not is_update:
62
- doc_id = ObjectId()
63
- if is_save and not is_update:
64
- self._id.value = doc_id # type: ignore[attr-defined]
65
- #
57
+
58
+ doc_id: ObjectId | None = None
59
+ is_update: bool = False
60
+ if is_migrate_model:
61
+ # Get the document ID.
62
+ doc_id = self._id.value # type: ignore[attr-defined]
63
+ # Does the document exist in the database?
64
+ is_update = doc_id is not None
65
+ # Create an identifier for a new document.
66
+ if is_save and not is_update:
67
+ doc_id = ObjectId()
68
+ self._id.value = doc_id # type: ignore[attr-defined]
69
+
66
70
  result_map: dict[str, Any] = {}
67
71
  # Errors from additional validation of fields.
68
72
  error_map: dict[str, str] = await self.add_validation() or {} # type: ignore[attr-defined]
@@ -81,7 +85,7 @@ class CheckMixin(
81
85
  "full_model_name": cls_model.META["full_model_name"], # type: ignore[attr-defined]
82
86
  "is_migrate_model": is_migrate_model,
83
87
  }
84
- #
88
+
85
89
  # Run checking fields.
86
90
  for field_name, field_data in self.__dict__.items():
87
91
  if callable(field_data):
ramifice/pseudo_model.py CHANGED
@@ -12,7 +12,6 @@ from dateutil.parser import parse
12
12
 
13
13
  from . import translations
14
14
  from .errors import PanicError
15
- from .fields import IDField # type: ignore[attr-defined]
16
15
 
17
16
 
18
17
  class PseudoModel(metaclass=ABCMeta):
@@ -24,13 +23,6 @@ class PseudoModel(metaclass=ABCMeta):
24
23
  META: dict[str, Any] = {}
25
24
 
26
25
  def __init__(self) -> None: # noqa: D107
27
- self._id = IDField(
28
- label="Stub",
29
- placeholder="Stub",
30
- hint="Stub",
31
- hide=True,
32
- disabled=True,
33
- )
34
26
  self.fields()
35
27
  self.inject()
36
28
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ramifice
3
- Version: 0.3.22
3
+ Version: 0.3.24
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/
@@ -142,6 +142,7 @@ from ramifice.migration import Monitor
142
142
  @model(service_name="Accounts")
143
143
  class User:
144
144
  def fields(self):
145
+ # For custom translations.
145
146
  gettext = translations.gettext
146
147
  # ngettext = translations.ngettext
147
148
  self.avatar = ImageField(
@@ -230,7 +231,7 @@ if __name__ == "__main__":
230
231
  asyncio.run(main())
231
232
  ```
232
233
 
233
- ### For create custom translations
234
+ ### How to create custom translations ?
234
235
 
235
236
  ```python
236
237
  from ramifice import translations
@@ -246,21 +247,40 @@ uv run pybabel extract -o config/translations/custom.pot src
246
247
  uv run pybabel init -i config/translations/custom.pot -d config/translations/custom -l en
247
248
  uv run pybabel init -i config/translations/custom.pot -d config/translations/custom -l ru
248
249
  ...
250
+
251
+ # Hint: Do not forget to add translations for new languages.
249
252
  uv run pybabel compile -d config/translations/custom
253
+
250
254
  # Update your custom translations:
251
255
  uv run pybabel extract -o config/translations/custom.pot src
252
256
  uv run pybabel update -i config/translations/custom.pot -d config/translations/custom
257
+ # Hint: Do not forget to check the translations for existing languages.
253
258
  uv run pybabel compile -d config/translations/custom
254
- #
255
- # Add new languages ​​to Ramifice:
259
+ ```
260
+
261
+ ### How to add new languages ​​to Ramifice ?
262
+
263
+ ```python
264
+ from ramifice import translations
265
+
266
+ translations.DEFAULT_LOCALE = "en" # For Ramifice by default = "en"
267
+ translations.LANGUAGES = ["en", "ru", "de", "de_ch"] # For Ramifice by default = ["en", "ru"]
268
+ ```
269
+
270
+ ```shell
271
+ cd project_name
256
272
  # Example:
257
273
  uv run pybabel init -i config/translations/ramifice.pot -d config/translations/ramifice -l de
258
274
  uv run pybabel init -i config/translations/ramifice.pot -d config/translations/ramifice -l de_ch
259
275
  ...
276
+
277
+ # Hint: Do not forget to add translations for new languages.
260
278
  uv run pybabel compile -d config/translations/ramifice
279
+
261
280
  # Update translations to Ramifice:
262
281
  uv run pybabel extract -o config/translations/ramifice.pot ramifice
263
282
  uv run pybabel update -i config/translations/ramifice.pot -d config/translations/ramifice
283
+ # Hint: Do not forget to check the translations for existing languages.
264
284
  uv run pybabel compile -d config/translations/ramifice
265
285
  ```
266
286
 
@@ -1,6 +1,6 @@
1
1
  ramifice/__init__.py,sha256=jOSfXKsCkSk7y_mkKMF32gKotkD8V4RmQYvPh4smVVE,679
2
2
  ramifice/add_valid.py,sha256=kvpMg7snL9tor0A23XRdgwiXazRwHfb8baoJUNjM_4Y,327
3
- ramifice/decorators.py,sha256=0_KKq2u7mX12iqWp4-vfGBR4cKqfkey7gL5P9C7bBNQ,6811
3
+ ramifice/decorators.py,sha256=VSAnaD8ZtDzpzNqdTgRKZcYGNm8aJQm9ITChGl4UcEM,6838
4
4
  ramifice/errors.py,sha256=iuhq7fzpUmsOyeXeg2fJjta8yAuqlXLKsZVMpfUhtHE,1901
5
5
  ramifice/fixtures.py,sha256=NtxOnZslYJb4yvRpZbs3ckugmTwHQFS_9iCt2zddOC0,3102
6
6
  ramifice/hooks.py,sha256=Ri-ISfMT-IHaLO2eAqg8CODCTs3HRTxSylqspUKnVf4,873
@@ -8,7 +8,7 @@ ramifice/indexing.py,sha256=wQpX2qei5Zc7iIq5yIV93Skp8Aa8ZD0vybnEk7cRuXs,271
8
8
  ramifice/migration.py,sha256=t_Rm1OUQYrlaPQQd1uS5S7EYMvSuKUcWzi7P4JMkrOw,11114
9
9
  ramifice/mixins.py,sha256=gKLmWQ-QrGO3K5_k-h1tDa08lkCql_dte2Jy05q1wsM,1125
10
10
  ramifice/model.py,sha256=xhLKosxnT3HkPr6j_BSkB7pvG2WNY_7uylcHo3Oq0vM,6521
11
- ramifice/pseudo_model.py,sha256=D2eW6gYDKxSLOXyyeIOyP2k84vsaISGXytBHoiLwRdU,6981
11
+ ramifice/pseudo_model.py,sha256=K00TqtrO6QScfAswM3Rr5Y017PfbtEXHymGSJYYgA40,6744
12
12
  ramifice/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  ramifice/store.py,sha256=MpDEPvUvbs11FXjakNtHPm9MekIv5p1U3as2Y80lTyc,1860
14
14
  ramifice/translations.py,sha256=GNGE0ULAA0aOY5pTxUd3MQW-nVaKvp6BeXWEcsR0s0o,4048
@@ -58,7 +58,7 @@ ramifice/fields/general/file_group.py,sha256=n45KfPzFI_l5hXoKkPDG0Q-0mdC2obExV-3
58
58
  ramifice/fields/general/number_group.py,sha256=AqlCY-t6JHZ2QVBe7mk5nPt6z8M4VJ_RARRlSBoIxms,715
59
59
  ramifice/fields/general/text_group.py,sha256=gP6mUGXr-LTI1UegqgEMQ-5vtUJuJs0wDYKVkknW_5E,873
60
60
  ramifice/paladins/__init__.py,sha256=PIP3AXI2KBRXNcLJUF0d7ygJ7VLOAxlhb4HRKQ9MGYY,516
61
- ramifice/paladins/check.py,sha256=W1eJRWxcaoKIFawJOF8rshy2-SKSPPuKXms9rxN7y64,6938
61
+ ramifice/paladins/check.py,sha256=h07UX4OKa_1X4Wt3rC-qAAZ8xd-d0rGYlqprXE4CXk0,7009
62
62
  ramifice/paladins/delete.py,sha256=RfCyew5tbBCT8u1c8nMgC2vIQlIWzu9Tvh6TuO7VBmM,3584
63
63
  ramifice/paladins/password.py,sha256=O1OvmeKuXbwtBX1sPTRVsoWYHPQn9isOe1rju6A3wbE,3264
64
64
  ramifice/paladins/refrash.py,sha256=DfBFGjPB6yYjga57GuCiWFBNHalmDO3EfMjkhgoWnVI,1207
@@ -76,7 +76,7 @@ ramifice/paladins/groups/num_group.py,sha256=lpyFG9a6WGOzu9f_9jwYVWZNFHxG0B0AVWv
76
76
  ramifice/paladins/groups/pass_group.py,sha256=7EXqssszWQaDldJgvyNFFPxj1KSdCN89xFXrfYTTZTQ,1817
77
77
  ramifice/paladins/groups/slug_group.py,sha256=SVYxHcSSgCA51C18LVGxMQYuUw-6ryQlTi6B9T8Dzsw,2185
78
78
  ramifice/paladins/groups/text_group.py,sha256=N_uHsL-JJnNp2JIzNxmNyK9hRupdZGTx9Cbe6muKSmI,3128
79
- ramifice-0.3.22.dist-info/METADATA,sha256=YpuZPDu3wd9tubh_VDZdCSVQbl_aEaq1kZPjYqA_isU,18904
80
- ramifice-0.3.22.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
81
- ramifice-0.3.22.dist-info/licenses/LICENSE,sha256=LrEL0aTZx90HDwFUQCJutORiDjJL9AnuVvCtspXIqt4,1095
82
- ramifice-0.3.22.dist-info/RECORD,,
79
+ ramifice-0.3.24.dist-info/METADATA,sha256=2E65Rusy36Wzss6AZM6sM4yAR_qwiSDfFB0XkoEckMg,19467
80
+ ramifice-0.3.24.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
81
+ ramifice-0.3.24.dist-info/licenses/LICENSE,sha256=LrEL0aTZx90HDwFUQCJutORiDjJL9AnuVvCtspXIqt4,1095
82
+ ramifice-0.3.24.dist-info/RECORD,,