ramifice 0.8.22__py3-none-any.whl → 0.8.26__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/__init__.py +8 -1
- ramifice/commons/__init__.py +2 -2
- ramifice/commons/general.py +11 -11
- ramifice/commons/indexes.py +8 -8
- ramifice/commons/many.py +6 -6
- ramifice/commons/one.py +8 -8
- ramifice/commons/tools.py +4 -4
- ramifice/commons/unit_manager.py +3 -3
- ramifice/fields/__init__.py +1 -1
- ramifice/fields/bool_field.py +16 -6
- ramifice/fields/choice_float_dyn_field.py +16 -6
- ramifice/fields/choice_float_field.py +20 -8
- ramifice/fields/choice_float_mult_dyn_field.py +16 -6
- ramifice/fields/choice_float_mult_field.py +20 -8
- ramifice/fields/choice_int_dyn_field.py +16 -6
- ramifice/fields/choice_int_field.py +20 -8
- ramifice/fields/choice_int_mult_dyn_field.py +16 -6
- ramifice/fields/choice_int_mult_field.py +20 -8
- ramifice/fields/choice_text_dyn_field.py +16 -6
- ramifice/fields/choice_text_field.py +20 -8
- ramifice/fields/choice_text_mult_dyn_field.py +16 -6
- ramifice/fields/choice_text_mult_field.py +20 -8
- ramifice/fields/color_field.py +24 -11
- ramifice/fields/date_field.py +25 -10
- ramifice/fields/date_time_field.py +25 -10
- ramifice/fields/email_field.py +21 -7
- ramifice/fields/file_field.py +25 -10
- ramifice/fields/float_field.py +25 -7
- ramifice/fields/general/__init__.py +1 -1
- ramifice/fields/general/choice_group.py +9 -10
- ramifice/fields/general/date_group.py +11 -11
- ramifice/fields/general/field.py +13 -13
- ramifice/fields/general/file_group.py +10 -10
- ramifice/fields/general/number_group.py +8 -8
- ramifice/fields/general/text_group.py +10 -10
- ramifice/fields/id_field.py +20 -15
- ramifice/fields/image_field.py +25 -9
- ramifice/fields/integer_field.py +25 -7
- ramifice/fields/ip_field.py +21 -7
- ramifice/fields/password_field.py +21 -12
- ramifice/fields/phone_field.py +22 -8
- ramifice/fields/slug_field.py +17 -6
- ramifice/fields/text_field.py +24 -7
- ramifice/fields/url_field.py +19 -19
- ramifice/models/__init__.py +7 -1
- ramifice/models/decorator.py +3 -3
- ramifice/models/model.py +16 -16
- ramifice/paladins/__init__.py +17 -2
- ramifice/paladins/add_valid.py +3 -3
- ramifice/paladins/check.py +3 -3
- ramifice/paladins/delete.py +3 -3
- ramifice/paladins/groups/__init__.py +1 -1
- ramifice/paladins/groups/bool_group.py +3 -3
- ramifice/paladins/groups/choice_group.py +3 -3
- ramifice/paladins/groups/date_group.py +3 -3
- ramifice/paladins/groups/file_group.py +3 -3
- ramifice/paladins/groups/id_group.py +3 -3
- ramifice/paladins/groups/img_group.py +3 -3
- ramifice/paladins/groups/num_group.py +3 -3
- ramifice/paladins/groups/pass_group.py +3 -3
- ramifice/paladins/groups/slug_group.py +3 -3
- ramifice/paladins/groups/text_group.py +3 -3
- ramifice/paladins/hooks.py +8 -8
- ramifice/paladins/indexing.py +3 -3
- ramifice/paladins/password.py +4 -4
- ramifice/paladins/refrash.py +3 -3
- ramifice/paladins/save.py +3 -3
- ramifice/paladins/tools.py +6 -6
- ramifice/paladins/validation.py +4 -4
- ramifice/utils/__init__.py +13 -1
- ramifice/utils/constants.py +1 -1
- ramifice/utils/errors.py +23 -23
- ramifice/utils/fixtures.py +2 -2
- ramifice/utils/migration.py +8 -8
- ramifice/utils/{mixins/json_converter.py → mixins.py} +6 -6
- ramifice/utils/tools.py +12 -12
- ramifice/utils/translations.py +5 -5
- ramifice/utils/unit.py +10 -10
- {ramifice-0.8.22.dist-info → ramifice-0.8.26.dist-info}/METADATA +4 -4
- ramifice-0.8.26.dist-info/RECORD +83 -0
- ramifice/utils/mixins/__init__.py +0 -5
- ramifice-0.8.22.dist-info/RECORD +0 -84
- {ramifice-0.8.22.dist-info → ramifice-0.8.26.dist-info}/WHEEL +0 -0
- {ramifice-0.8.22.dist-info → ramifice-0.8.26.dist-info}/licenses/LICENSE +0 -0
ramifice/paladins/__init__.py
CHANGED
@@ -1,4 +1,19 @@
|
|
1
|
-
"""
|
1
|
+
"""Paladins - Model instance methods.
|
2
|
+
|
3
|
+
This module provides:
|
4
|
+
|
5
|
+
- `add_validation`: Contains an abstract method for additional validation of fields.
|
6
|
+
- `check`: Validation of Model data before saving to the database.
|
7
|
+
- `delete`: Delete document from database.
|
8
|
+
- `Hooks`: A set of abstract methods for creating hooks.
|
9
|
+
- `indexing`: Contains the method for indexing the model in the database.
|
10
|
+
- `password`: Verification, replacement and recoverang of password.
|
11
|
+
- `refrash_from_db`: Update Model instance from database.
|
12
|
+
- `save`: Create or update document in database.
|
13
|
+
- `Tools`: A set of auxiliary methods.
|
14
|
+
- `is_valid`: Validation of Model.
|
15
|
+
- `print_err`: Printing errors to console.
|
16
|
+
"""
|
2
17
|
|
3
18
|
__all__ = ("QPaladinsMixin",)
|
4
19
|
|
@@ -24,7 +39,7 @@ class QPaladinsMixin(
|
|
24
39
|
HooksMixin,
|
25
40
|
IndexMixin,
|
26
41
|
):
|
27
|
-
"""
|
42
|
+
"""Paladins - Model instance methods."""
|
28
43
|
|
29
44
|
def __init__(self) -> None: # noqa: D107
|
30
45
|
super().__init__()
|
ramifice/paladins/add_valid.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""AddValidMixin - Contains an abstract method for additional validation of fields."""
|
2
2
|
|
3
3
|
__all__ = ("AddValidMixin",)
|
4
4
|
|
@@ -8,8 +8,8 @@ from xloft import NamedTuple
|
|
8
8
|
|
9
9
|
|
10
10
|
class AddValidMixin(metaclass=ABCMeta):
|
11
|
-
"""
|
11
|
+
"""Contains an abstract method for additional validation of fields."""
|
12
12
|
|
13
13
|
async def add_validation(self) -> NamedTuple:
|
14
|
-
"""
|
14
|
+
"""Additional validation of fields."""
|
15
15
|
return NamedTuple()
|
ramifice/paladins/check.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Validation of Model data before saving to the database."""
|
2
2
|
|
3
3
|
__all__ = ("CheckMixin",)
|
4
4
|
|
@@ -40,7 +40,7 @@ class CheckMixin(
|
|
40
40
|
SlugGroupMixin,
|
41
41
|
TextGroupMixin,
|
42
42
|
):
|
43
|
-
"""
|
43
|
+
"""Validation of Model data before saving to the database."""
|
44
44
|
|
45
45
|
async def check(
|
46
46
|
self,
|
@@ -48,7 +48,7 @@ class CheckMixin(
|
|
48
48
|
collection: AsyncCollection | None = None,
|
49
49
|
is_migration_process: bool = False,
|
50
50
|
) -> dict[str, Any]:
|
51
|
-
"""
|
51
|
+
"""Validation of Model data before saving to the database.
|
52
52
|
|
53
53
|
It is also used to verify Models that do not migrate to the database.
|
54
54
|
"""
|
ramifice/paladins/delete.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Delete document from database."""
|
2
2
|
|
3
3
|
__all__ = ("DeleteMixin",)
|
4
4
|
|
@@ -17,7 +17,7 @@ logger = logging.getLogger(__name__)
|
|
17
17
|
|
18
18
|
|
19
19
|
class DeleteMixin:
|
20
|
-
"""
|
20
|
+
"""Delete document from database."""
|
21
21
|
|
22
22
|
async def delete(
|
23
23
|
self,
|
@@ -30,7 +30,7 @@ class DeleteMixin:
|
|
30
30
|
comment: Any | None = None,
|
31
31
|
**kwargs: dict[str, Any],
|
32
32
|
) -> dict[str, Any]:
|
33
|
-
"""
|
33
|
+
"""Delete document from database."""
|
34
34
|
cls_model = self.__class__
|
35
35
|
# Raises a panic if the Model cannot be removed.
|
36
36
|
if not cls_model.META["is_delete_doc"]:
|
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Group for checking boolean fields.
|
2
2
|
|
3
3
|
Supported fields:
|
4
4
|
BooleanField
|
@@ -12,14 +12,14 @@ from ramifice.paladins.tools import panic_type_error
|
|
12
12
|
|
13
13
|
|
14
14
|
class BoolGroupMixin:
|
15
|
-
"""
|
15
|
+
"""Group for checking boolean fields.
|
16
16
|
|
17
17
|
Supported fields:
|
18
18
|
BooleanField
|
19
19
|
"""
|
20
20
|
|
21
21
|
def bool_group(self, params: dict[str, Any]) -> None:
|
22
|
-
"""
|
22
|
+
"""Checking boolean fields."""
|
23
23
|
field = params["field_data"]
|
24
24
|
# Get current value.
|
25
25
|
value = field.value
|
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Group for checking choice fields.
|
2
2
|
|
3
3
|
Supported fields:
|
4
4
|
ChoiceTextMultField | ChoiceTextMultDynField | ChoiceTextField
|
@@ -16,7 +16,7 @@ from ramifice.utils import translations
|
|
16
16
|
|
17
17
|
|
18
18
|
class ChoiceGroupMixin:
|
19
|
-
"""
|
19
|
+
"""Group for checking choice fields.
|
20
20
|
|
21
21
|
Supported fields:
|
22
22
|
ChoiceTextMultField | ChoiceTextMultDynField | ChoiceTextField
|
@@ -26,7 +26,7 @@ class ChoiceGroupMixin:
|
|
26
26
|
"""
|
27
27
|
|
28
28
|
def choice_group(self, params: dict[str, Any]) -> None:
|
29
|
-
"""
|
29
|
+
"""Checking choice fields."""
|
30
30
|
field = params["field_data"]
|
31
31
|
is_migrate = params["is_migration_process"]
|
32
32
|
# Get current value.
|
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Group for checking date fields.
|
2
2
|
|
3
3
|
Supported fields:
|
4
4
|
DateTimeField | DateField
|
@@ -19,14 +19,14 @@ from ramifice.utils import translations
|
|
19
19
|
|
20
20
|
|
21
21
|
class DateGroupMixin:
|
22
|
-
"""
|
22
|
+
"""Group for checking date fields.
|
23
23
|
|
24
24
|
Supported fields:
|
25
25
|
DateTimeField | DateField
|
26
26
|
"""
|
27
27
|
|
28
28
|
def date_group(self, params: dict[str, Any]) -> None:
|
29
|
-
"""
|
29
|
+
"""Checking date fields."""
|
30
30
|
field = params["field_data"]
|
31
31
|
# Get current value.
|
32
32
|
value = field.value or field.default or None
|
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Group for checking file fields.
|
2
2
|
|
3
3
|
Supported fields: FileField
|
4
4
|
"""
|
@@ -16,13 +16,13 @@ from ramifice.utils.tools import to_human_size
|
|
16
16
|
|
17
17
|
|
18
18
|
class FileGroupMixin:
|
19
|
-
"""
|
19
|
+
"""Group for checking file fields.
|
20
20
|
|
21
21
|
Supported fields: FileField
|
22
22
|
"""
|
23
23
|
|
24
24
|
async def file_group(self, params: dict[str, Any]) -> None:
|
25
|
-
"""
|
25
|
+
"""Checking file fields."""
|
26
26
|
field = params["field_data"]
|
27
27
|
value = field.value or None
|
28
28
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Group for checking id fields.
|
2
2
|
|
3
3
|
Supported fields:
|
4
4
|
IDField
|
@@ -15,14 +15,14 @@ from ramifice.utils import translations
|
|
15
15
|
|
16
16
|
|
17
17
|
class IDGroupMixin:
|
18
|
-
"""
|
18
|
+
"""Group for checking id fields.
|
19
19
|
|
20
20
|
Supported fields:
|
21
21
|
IDField
|
22
22
|
"""
|
23
23
|
|
24
24
|
def id_group(self, params: dict[str, Any]) -> None:
|
25
|
-
"""
|
25
|
+
"""Checking id fields."""
|
26
26
|
field = params["field_data"]
|
27
27
|
# Get current value.
|
28
28
|
value = field.value
|
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Group for checking image fields.
|
2
2
|
|
3
3
|
Supported fields: ImageField
|
4
4
|
"""
|
@@ -16,13 +16,13 @@ from ramifice.utils.tools import to_human_size
|
|
16
16
|
|
17
17
|
|
18
18
|
class ImgGroupMixin:
|
19
|
-
"""
|
19
|
+
"""Group for checking image fields.
|
20
20
|
|
21
21
|
Supported fields: ImageField
|
22
22
|
"""
|
23
23
|
|
24
24
|
async def img_group(self, params: dict[str, Any]) -> None:
|
25
|
-
"""
|
25
|
+
"""Checking image fields."""
|
26
26
|
field = params["field_data"]
|
27
27
|
value = field.value or None
|
28
28
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Group for checking integer fields.
|
2
2
|
|
3
3
|
Supported fields:
|
4
4
|
IntegerField | FloatField
|
@@ -17,14 +17,14 @@ from ramifice.utils import translations
|
|
17
17
|
|
18
18
|
|
19
19
|
class NumGroupMixin:
|
20
|
-
"""
|
20
|
+
"""Group for checking integer fields.
|
21
21
|
|
22
22
|
Supported fields:
|
23
23
|
IntegerField | FloatField
|
24
24
|
"""
|
25
25
|
|
26
26
|
async def num_group(self, params: dict[str, Any]) -> None:
|
27
|
-
"""
|
27
|
+
"""Checking number fields."""
|
28
28
|
field = params["field_data"]
|
29
29
|
field_name = field.name
|
30
30
|
# Get current value.
|
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Group for checking password fields.
|
2
2
|
|
3
3
|
Supported fields: PasswordField
|
4
4
|
"""
|
@@ -15,13 +15,13 @@ from ramifice.utils.tools import is_password
|
|
15
15
|
|
16
16
|
|
17
17
|
class PassGroupMixin:
|
18
|
-
"""
|
18
|
+
"""Group for checking password fields.
|
19
19
|
|
20
20
|
Supported fields: PasswordField
|
21
21
|
"""
|
22
22
|
|
23
23
|
def pass_group(self, params: dict[str, Any]) -> None:
|
24
|
-
"""
|
24
|
+
"""Checking password fields."""
|
25
25
|
field = params["field_data"]
|
26
26
|
# When updating the document, skip the verification.
|
27
27
|
if params["is_update"]:
|
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Group for checking slug fields.
|
2
2
|
|
3
3
|
Supported fields:
|
4
4
|
SlugField
|
@@ -18,14 +18,14 @@ logger = logging.getLogger(__name__)
|
|
18
18
|
|
19
19
|
|
20
20
|
class SlugGroupMixin:
|
21
|
-
"""
|
21
|
+
"""Group for checking slug fields.
|
22
22
|
|
23
23
|
Supported fields:
|
24
24
|
SlugField
|
25
25
|
"""
|
26
26
|
|
27
27
|
async def slug_group(self, params: dict[str, Any]) -> None:
|
28
|
-
"""
|
28
|
+
"""Checking slug fields."""
|
29
29
|
if not params["is_save"]:
|
30
30
|
return
|
31
31
|
#
|
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Group for checking text fields.
|
2
2
|
|
3
3
|
Supported fields:
|
4
4
|
URLField | TextField | PhoneField
|
@@ -30,7 +30,7 @@ from ramifice.utils.tools import (
|
|
30
30
|
|
31
31
|
|
32
32
|
class TextGroupMixin:
|
33
|
-
"""
|
33
|
+
"""Group for checking text fields.
|
34
34
|
|
35
35
|
Supported fields:
|
36
36
|
URLField | TextField | PhoneField
|
@@ -38,7 +38,7 @@ class TextGroupMixin:
|
|
38
38
|
"""
|
39
39
|
|
40
40
|
async def text_group(self, params: dict[str, Any]) -> None:
|
41
|
-
"""
|
41
|
+
"""Checking text fields."""
|
42
42
|
field = params["field_data"]
|
43
43
|
field_name = field.name
|
44
44
|
field_type: str = field.field_type
|
ramifice/paladins/hooks.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""HooksMixin - Contains abstract methods for creating hooks."""
|
2
2
|
|
3
3
|
__all__ = ("HooksMixin",)
|
4
4
|
|
@@ -6,22 +6,22 @@ from abc import ABCMeta
|
|
6
6
|
|
7
7
|
|
8
8
|
class HooksMixin(metaclass=ABCMeta):
|
9
|
-
"""
|
9
|
+
"""A set of abstract methods for creating hooks."""
|
10
10
|
|
11
11
|
async def pre_create(self) -> None:
|
12
|
-
"""
|
12
|
+
"""Called before a new document is created in the database."""
|
13
13
|
|
14
14
|
async def post_create(self) -> None:
|
15
|
-
"""
|
15
|
+
"""Called after a new document has been created in the database."""
|
16
16
|
|
17
17
|
async def pre_update(self) -> None:
|
18
|
-
"""
|
18
|
+
"""Called before updating an existing document in the database."""
|
19
19
|
|
20
20
|
async def post_update(self) -> None:
|
21
|
-
"""
|
21
|
+
"""Called after an existing document in the database is updated."""
|
22
22
|
|
23
23
|
async def pre_delete(self) -> None:
|
24
|
-
"""
|
24
|
+
"""Called before deleting an existing document in the database."""
|
25
25
|
|
26
26
|
async def post_delete(self) -> None:
|
27
|
-
"""
|
27
|
+
"""Called after an existing document in the database has been deleted."""
|
ramifice/paladins/indexing.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""IndexMixin - Contains abstract method for indexing the model in the database."""
|
2
2
|
|
3
3
|
__all__ = ("IndexMixin",)
|
4
4
|
|
@@ -6,8 +6,8 @@ from abc import ABCMeta
|
|
6
6
|
|
7
7
|
|
8
8
|
class IndexMixin(metaclass=ABCMeta):
|
9
|
-
"""
|
9
|
+
"""Contains the method for indexing the model in the database."""
|
10
10
|
|
11
11
|
@classmethod
|
12
12
|
async def indexing(cls) -> None:
|
13
|
-
"""
|
13
|
+
"""Set up and start indexing."""
|
ramifice/paladins/password.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Verification, replacement and recoverang of password."""
|
2
2
|
|
3
3
|
__all__ = ("PasswordMixin",)
|
4
4
|
|
@@ -15,14 +15,14 @@ logger = logging.getLogger(__name__)
|
|
15
15
|
|
16
16
|
|
17
17
|
class PasswordMixin:
|
18
|
-
"""
|
18
|
+
"""Verification, replacement and recoverang of password."""
|
19
19
|
|
20
20
|
async def verify_password(
|
21
21
|
self,
|
22
22
|
password: str,
|
23
23
|
field_name: str = "password",
|
24
24
|
) -> bool:
|
25
|
-
"""
|
25
|
+
"""For password verification."""
|
26
26
|
cls_model = self.__class__
|
27
27
|
# Get documet ID.
|
28
28
|
doc_id = self._id.value
|
@@ -76,7 +76,7 @@ class PasswordMixin:
|
|
76
76
|
new_password: str,
|
77
77
|
field_name: str = "password",
|
78
78
|
) -> None:
|
79
|
-
"""
|
79
|
+
"""For replace or recover password."""
|
80
80
|
cls_model = self.__class__
|
81
81
|
if not await self.verify_password(old_password, field_name):
|
82
82
|
logger.warning("Old password does not match!")
|
ramifice/paladins/refrash.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Update Model instance from database."""
|
2
2
|
|
3
3
|
__all__ = ("RefrashMixin",)
|
4
4
|
|
@@ -15,10 +15,10 @@ logger = logging.getLogger(__name__)
|
|
15
15
|
|
16
16
|
|
17
17
|
class RefrashMixin:
|
18
|
-
"""
|
18
|
+
"""Update Model instance from database."""
|
19
19
|
|
20
20
|
async def refrash_from_db(self) -> None:
|
21
|
-
"""
|
21
|
+
"""Update Model instance from database."""
|
22
22
|
cls_model = self.__class__
|
23
23
|
# Get collection.
|
24
24
|
collection: AsyncCollection = constants.MONGO_DATABASE[cls_model.META["collection_name"]]
|
ramifice/paladins/save.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Create or update document in database."""
|
2
2
|
|
3
3
|
__all__ = ("SaveMixin",)
|
4
4
|
|
@@ -16,10 +16,10 @@ logger = logging.getLogger(__name__)
|
|
16
16
|
|
17
17
|
|
18
18
|
class SaveMixin:
|
19
|
-
"""
|
19
|
+
"""Create or update document in database."""
|
20
20
|
|
21
21
|
async def save(self) -> bool:
|
22
|
-
"""
|
22
|
+
"""Create or update document in database.
|
23
23
|
|
24
24
|
This method pre-uses the `check` method.
|
25
25
|
"""
|
ramifice/paladins/tools.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Tool of Paladins - A set of auxiliary methods."""
|
2
2
|
|
3
3
|
__all__ = (
|
4
4
|
"ignored_fields_to_none",
|
@@ -17,14 +17,14 @@ logger = logging.getLogger(__name__)
|
|
17
17
|
|
18
18
|
|
19
19
|
def ignored_fields_to_none(inst_model: Any) -> None:
|
20
|
-
"""
|
20
|
+
"""Reset the values of ignored fields to None."""
|
21
21
|
for _, field_data in inst_model.__dict__.items():
|
22
22
|
if not callable(field_data) and field_data.ignored:
|
23
23
|
field_data.value = None
|
24
24
|
|
25
25
|
|
26
26
|
def refresh_from_mongo_doc(inst_model: Any, mongo_doc: dict[str, Any]) -> None:
|
27
|
-
"""
|
27
|
+
"""Update object instance from Mongo document."""
|
28
28
|
lang: str = translations.CURRENT_LOCALE
|
29
29
|
model_dict = inst_model.__dict__
|
30
30
|
for name, data in mongo_doc.items():
|
@@ -38,7 +38,7 @@ def refresh_from_mongo_doc(inst_model: Any, mongo_doc: dict[str, Any]) -> None:
|
|
38
38
|
|
39
39
|
|
40
40
|
def panic_type_error(value_type: str, params: dict[str, Any]) -> None:
|
41
|
-
"""
|
41
|
+
"""Unacceptable type of value."""
|
42
42
|
msg = (
|
43
43
|
f"Model: `{params['full_model_name']}` > "
|
44
44
|
+ f"Field: `{params['field_data'].name}` > "
|
@@ -49,7 +49,7 @@ def panic_type_error(value_type: str, params: dict[str, Any]) -> None:
|
|
49
49
|
|
50
50
|
|
51
51
|
def accumulate_error(err_msg: str, params: dict[str, Any]) -> None:
|
52
|
-
"""
|
52
|
+
"""Accumulating errors to ModelName.field_name.errors ."""
|
53
53
|
if not params["field_data"].hide:
|
54
54
|
params["field_data"].errors.append(err_msg)
|
55
55
|
if not params["is_error_symptom"]:
|
@@ -70,7 +70,7 @@ async def check_uniqueness(
|
|
70
70
|
field_name: str | None = None,
|
71
71
|
is_multi_language: bool = False,
|
72
72
|
) -> bool:
|
73
|
-
"""
|
73
|
+
"""Checking the uniqueness of the value in the collection."""
|
74
74
|
q_filter = None
|
75
75
|
if is_multi_language:
|
76
76
|
lang_filter = [{f"{field_name}.{lang}": value} for lang in translations.LANGUAGES]
|
ramifice/paladins/validation.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Validation of Model and printing errors to console."""
|
2
2
|
|
3
3
|
__all__ = ("ValidationMixin",)
|
4
4
|
|
@@ -8,10 +8,10 @@ from termcolor import colored
|
|
8
8
|
|
9
9
|
|
10
10
|
class ValidationMixin:
|
11
|
-
"""
|
11
|
+
"""Validation of Model and printing errors to console."""
|
12
12
|
|
13
13
|
async def is_valid(self) -> bool:
|
14
|
-
"""
|
14
|
+
"""Check data validity.
|
15
15
|
|
16
16
|
The main use is to check data from web forms.
|
17
17
|
It is also used to verify Models that do not migrate to the database.
|
@@ -20,7 +20,7 @@ class ValidationMixin:
|
|
20
20
|
return result_check["is_valid"]
|
21
21
|
|
22
22
|
def print_err(self) -> None:
|
23
|
-
"""
|
23
|
+
"""Printing errors to console.
|
24
24
|
|
25
25
|
Convenient to use during development.
|
26
26
|
"""
|
ramifice/utils/__init__.py
CHANGED
@@ -1 +1,13 @@
|
|
1
|
-
"""
|
1
|
+
"""A set of Ramifice useful utilities.
|
2
|
+
|
3
|
+
This module includes:
|
4
|
+
|
5
|
+
- `constants` - Global variables.
|
6
|
+
- `errors` - Custom Exceptions for Ramifice.
|
7
|
+
- `fixtures` - To populate the database with pre-created data.
|
8
|
+
- `migration` - Migration of models to database.
|
9
|
+
- `mixins` - Set of mixins for Models and Fields.
|
10
|
+
- `tools` - Global collection of auxiliary methods.
|
11
|
+
- `translations` - Localization of translations.
|
12
|
+
- `unit` - Data management in dynamic fields.
|
13
|
+
"""
|
ramifice/utils/constants.py
CHANGED