ramifice 0.5.9__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.9
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/
@@ -130,14 +130,8 @@ import pprint
130
130
  from pymongo import AsyncMongoClient
131
131
  from ramifice import model, translations, migration
132
132
  from ramifice.fields import (
133
- BooleanField,
134
- DateField,
135
- DateTimeField,
136
- EmailField,
137
133
  ImageField,
138
134
  PasswordField,
139
- PhoneField,
140
- SlugField,
141
135
  TextField,
142
136
  )
143
137
  from ramifice.utils.tools import to_human_size
@@ -166,7 +160,7 @@ class User:
166
160
  high_quality=True,
167
161
  # The maximum size of the original image in bytes.
168
162
  # Hint: By default = 2 MB
169
- 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)
170
164
  warning=[
171
165
  gettext("Maximum size: %s") % to_human_size(524288),
172
166
  ],
@@ -181,40 +175,6 @@ class User:
181
175
  gettext("Allowed chars: %s") % "a-z A-Z 0-9 _",
182
176
  ],
183
177
  )
184
- self.first_name = TextField(
185
- label=gettext("First name"),
186
- placeholder=gettext("Enter your First name"),
187
- multi_language=True, # Support for several language.
188
- maxlength=150,
189
- required=True,
190
- )
191
- self.last_name = TextField(
192
- label=gettext("Last name"),
193
- placeholder=gettext("Enter your Last name"),
194
- multi_language=True, # Support for several language.
195
- maxlength=150,
196
- required=True,
197
- )
198
- self.email = EmailField(
199
- label=gettext("Email"),
200
- placeholder=gettext("Enter your email"),
201
- required=True,
202
- unique=True,
203
- )
204
- self.phone = PhoneField(
205
- label=gettext("Phone number"),
206
- placeholder=gettext("Enter your phone number"),
207
- unique=True,
208
- )
209
- self.birthday = DateField(
210
- label=gettext("Birthday"),
211
- placeholder=gettext("Enter your date of birth"),
212
- )
213
- self.description = TextField(
214
- label=gettext("About yourself"),
215
- placeholder=gettext("Tell us a little about yourself ..."),
216
- multi_language=True, # Support for several language.
217
- )
218
178
  self.password = PasswordField(
219
179
  label=gettext("Password"),
220
180
  placeholder=gettext("Enter your password"),
@@ -225,32 +185,7 @@ class User:
225
185
  # If true, the value of this field is not saved in the database.
226
186
  ignored=True,
227
187
  )
228
- self.is_admin = BooleanField(
229
- label=gettext("Is Administrator?"),
230
- warning=[
231
- gettext("Can this user access the admin panel?"),
232
- ],
233
- )
234
- self.is_active = BooleanField(
235
- label=gettext("Is active?"),
236
- warning=[
237
- gettext("Is this an active account?"),
238
- ],
239
- )
240
- self.slug = SlugField(
241
- label=gettext("Slug"),
242
- slug_sources=["username"],
243
- disabled=True,
244
- hide=True,
245
- )
246
- self.last_login = DateTimeField(
247
- label=gettext("Last login"),
248
- disabled=True,
249
- hide=True,
250
- warning=[
251
- gettext("Date and time of user last login."),
252
- ],
253
- )
188
+
254
189
 
255
190
  # Optional method.
256
191
  async def add_validation(self) -> dict[str, str]:
@@ -287,19 +222,8 @@ async def main():
287
222
  user = User()
288
223
  # user.avatar.from_path("public/media/default/no-photo.png")
289
224
  user.username.value = "pythondev"
290
- user.first_name.value = {"en": "John", "ru": "Джон"}
291
- # user.first_name.value = "John"
292
- user.last_name.value = {"en": "Smith", "ru": "Смит"}
293
- # user.last_name.value = "Smith"
294
- user.email.value = "John_Smith@gmail.com"
295
- user.phone.value = "+447986123456"
296
- user.birthday.value = datetime(2000, 1, 25)
297
- user.description.value = {"en": "I program on Python!", "ru": "Я программирую на Python!"}
298
- # user.description.value = "I program on Python!"
299
225
  user.password.value = "12345678"
300
226
  user.сonfirm_password.value = "12345678"
301
- user.is_admin.value = True
302
- user.is_active.value = True
303
227
 
304
228
  # Create User.
305
229
  if not await user.save():
@@ -335,9 +259,56 @@ if __name__ == "__main__":
335
259
  asyncio.run(main())
336
260
  ```
337
261
 
338
- ### 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
+ ```
339
296
 
340
- [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
+ ```
341
312
 
342
313
  ## Model Parameters
343
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.9.dist-info/METADATA,sha256=VvxAcFO4J_zyu9JOzW5yPh07agipqX1d-E-875n-Pe8,22372
83
- ramifice-0.5.9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
84
- ramifice-0.5.9.dist-info/licenses/LICENSE,sha256=LrEL0aTZx90HDwFUQCJutORiDjJL9AnuVvCtspXIqt4,1095
85
- ramifice-0.5.9.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,,