ramifice 0.5.8__py3-none-any.whl → 0.5.10__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ramifice
3
- Version: 0.5.8
3
+ Version: 0.5.10
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/
@@ -20,7 +20,6 @@ Classifier: Programming Language :: Python :: 3 :: Only
20
20
  Classifier: Programming Language :: Python :: 3.12
21
21
  Classifier: Programming Language :: Python :: 3.13
22
22
  Classifier: Programming Language :: Python :: Implementation :: CPython
23
- Classifier: Programming Language :: Python :: Implementation :: PyPy
24
23
  Classifier: Topic :: Database
25
24
  Classifier: Typing :: Typed
26
25
  Requires-Python: <4.0,>=3.12
@@ -131,14 +130,8 @@ import pprint
131
130
  from pymongo import AsyncMongoClient
132
131
  from ramifice import model, translations, migration
133
132
  from ramifice.fields import (
134
- BooleanField,
135
- DateField,
136
- DateTimeField,
137
- EmailField,
138
133
  ImageField,
139
134
  PasswordField,
140
- PhoneField,
141
- SlugField,
142
135
  TextField,
143
136
  )
144
137
  from ramifice.utils.tools import to_human_size
@@ -167,7 +160,7 @@ class User:
167
160
  high_quality=True,
168
161
  # The maximum size of the original image in bytes.
169
162
  # Hint: By default = 2 MB
170
- max_size=524288, # 512 KB = 0.5 MB = 524288 Bytes (in binary)
163
+ max_size=524288, # 0.5 MB = 512 KB = 524288 Bytes (in binary)
171
164
  warning=[
172
165
  gettext("Maximum size: %s") % to_human_size(524288),
173
166
  ],
@@ -182,40 +175,6 @@ class User:
182
175
  gettext("Allowed chars: %s") % "a-z A-Z 0-9 _",
183
176
  ],
184
177
  )
185
- self.first_name = TextField(
186
- label=gettext("First name"),
187
- placeholder=gettext("Enter your First name"),
188
- multi_language=True, # Support for several language.
189
- maxlength=150,
190
- required=True,
191
- )
192
- self.last_name = TextField(
193
- label=gettext("Last name"),
194
- placeholder=gettext("Enter your Last name"),
195
- multi_language=True, # Support for several language.
196
- maxlength=150,
197
- required=True,
198
- )
199
- self.email = EmailField(
200
- label=gettext("Email"),
201
- placeholder=gettext("Enter your email"),
202
- required=True,
203
- unique=True,
204
- )
205
- self.phone = PhoneField(
206
- label=gettext("Phone number"),
207
- placeholder=gettext("Enter your phone number"),
208
- unique=True,
209
- )
210
- self.birthday = DateField(
211
- label=gettext("Birthday"),
212
- placeholder=gettext("Enter your date of birth"),
213
- )
214
- self.description = TextField(
215
- label=gettext("About yourself"),
216
- placeholder=gettext("Tell us a little about yourself ..."),
217
- multi_language=True, # Support for several language.
218
- )
219
178
  self.password = PasswordField(
220
179
  label=gettext("Password"),
221
180
  placeholder=gettext("Enter your password"),
@@ -226,32 +185,7 @@ class User:
226
185
  # If true, the value of this field is not saved in the database.
227
186
  ignored=True,
228
187
  )
229
- self.is_admin = BooleanField(
230
- label=gettext("Is Administrator?"),
231
- warning=[
232
- gettext("Can this user access the admin panel?"),
233
- ],
234
- )
235
- self.is_active = BooleanField(
236
- label=gettext("Is active?"),
237
- warning=[
238
- gettext("Is this an active account?"),
239
- ],
240
- )
241
- self.slug = SlugField(
242
- label=gettext("Slug"),
243
- slug_sources=["username"],
244
- disabled=True,
245
- hide=True,
246
- )
247
- self.last_login = DateTimeField(
248
- label=gettext("Last login"),
249
- disabled=True,
250
- hide=True,
251
- warning=[
252
- gettext("Date and time of user last login."),
253
- ],
254
- )
188
+
255
189
 
256
190
  # Optional method.
257
191
  async def add_validation(self) -> dict[str, str]:
@@ -288,19 +222,8 @@ async def main():
288
222
  user = User()
289
223
  # user.avatar.from_path("public/media/default/no-photo.png")
290
224
  user.username.value = "pythondev"
291
- user.first_name.value = {"en": "John", "ru": "Джон"}
292
- # user.first_name.value = "John"
293
- user.last_name.value = {"en": "Smith", "ru": "Смит"}
294
- # user.last_name.value = "Smith"
295
- user.email.value = "John_Smith@gmail.com"
296
- user.phone.value = "+447986123456"
297
- user.birthday.value = datetime(2000, 1, 25)
298
- user.description.value = {"en": "I program on Python!", "ru": "Я программирую на Python!"}
299
- # user.description.value = "I program on Python!"
300
225
  user.password.value = "12345678"
301
226
  user.сonfirm_password.value = "12345678"
302
- user.is_admin.value = True
303
- user.is_active.value = True
304
227
 
305
228
  # Create User.
306
229
  if not await user.save():
@@ -336,9 +259,56 @@ if __name__ == "__main__":
336
259
  asyncio.run(main())
337
260
  ```
338
261
 
339
- ### How to add localization?
262
+ ### How to create custom translations ?
263
+
264
+ ```python
265
+ from ramifice import translations
266
+
267
+ translations.DEFAULT_LOCALE = "en" # For Ramifice by default = "en"
268
+ LANGUAGES = frozenset(("en", "ru")) # For Ramifice by default = ["en", "ru"]
269
+ ```
270
+
271
+ ```shell
272
+ cd project_name
273
+ # Add your custom translations:
274
+ uv run pybabel extract -o config/translations/custom.pot services
275
+ uv run pybabel init -i config/translations/custom.pot -d config/translations/custom -l en
276
+ uv run pybabel init -i config/translations/custom.pot -d config/translations/custom -l ru
277
+ ...
278
+ # Hint: Do not forget to add translations for new languages.
279
+ uv run pybabel compile -d config/translations/custom
280
+
281
+ # Update your custom translations:
282
+ uv run pybabel extract -o config/translations/custom.pot services
283
+ uv run pybabel update -i config/translations/custom.pot -d config/translations/custom
284
+ # Hint: Do not forget to check the translations for existing languages.
285
+ uv run pybabel compile -d config/translations/custom
286
+ ```
287
+
288
+ ### How to add new languages ​​to Ramifice ?
289
+
290
+ ```python
291
+ from ramifice import translations
292
+
293
+ translations.DEFAULT_LOCALE = "en" # For Ramifice by default = "en"
294
+ translations.LANGUAGES = frozenset(("en", "ru", "de", "de_ch")) # For Ramifice by default = ["en", "ru"]
295
+ ```
340
296
 
341
- [See in the examples.](https://github.com/kebasyaty/ramifice/tree/v0/examples "See in the examples.")
297
+ ```shell
298
+ cd project_name
299
+ # Example:
300
+ uv run pybabel init -i config/translations/ramifice.pot -d config/translations/ramifice -l de
301
+ uv run pybabel init -i config/translations/ramifice.pot -d config/translations/ramifice -l de_ch
302
+ ...
303
+ # Hint: Do not forget to add translations for new languages.
304
+ uv run pybabel compile -d config/translations/ramifice
305
+
306
+ # Update translations to Ramifice:
307
+ uv run pybabel extract -o config/translations/ramifice.pot ramifice
308
+ uv run pybabel update -i config/translations/ramifice.pot -d config/translations/ramifice
309
+ # Hint: Do not forget to check the translations for existing languages.
310
+ uv run pybabel compile -d config/translations/ramifice
311
+ ```
342
312
 
343
313
  ## Model Parameters
344
314
 
@@ -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.5.8.dist-info/METADATA,sha256=zaxbQjoDugoMSJd4tZESvDcUOgzkhEq0HGtAN_6yDJI,22441
83
- ramifice-0.5.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
84
- ramifice-0.5.8.dist-info/licenses/LICENSE,sha256=LrEL0aTZx90HDwFUQCJutORiDjJL9AnuVvCtspXIqt4,1095
85
- ramifice-0.5.8.dist-info/RECORD,,
82
+ ramifice-0.5.10.dist-info/METADATA,sha256=fxuQoD4MF3kNoMRn0UJDM3l4AThmLCPtPIW3aE9HRVc,21464
83
+ ramifice-0.5.10.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
84
+ ramifice-0.5.10.dist-info/licenses/LICENSE,sha256=LrEL0aTZx90HDwFUQCJutORiDjJL9AnuVvCtspXIqt4,1095
85
+ ramifice-0.5.10.dist-info/RECORD,,