ramifice 0.3.27__py3-none-any.whl → 0.3.29__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 +2 -1
- ramifice/commons/__init__.py +1 -3
- ramifice/commons/general.py +9 -9
- ramifice/commons/indexes.py +7 -7
- ramifice/commons/many.py +19 -15
- ramifice/commons/one.py +23 -13
- ramifice/commons/tools.py +62 -57
- ramifice/commons/{units.py → unit_manager.py} +5 -7
- ramifice/fields/bool_field.py +3 -3
- ramifice/fields/choice_float_dyn_field.py +3 -3
- ramifice/fields/choice_float_field.py +3 -3
- ramifice/fields/choice_float_mult_dyn_field.py +3 -3
- ramifice/fields/choice_float_mult_field.py +3 -3
- ramifice/fields/choice_int_dyn_field.py +3 -3
- ramifice/fields/choice_int_field.py +3 -3
- ramifice/fields/choice_int_mult_dyn_field.py +3 -3
- ramifice/fields/choice_int_mult_field.py +3 -3
- ramifice/fields/choice_text_dyn_field.py +3 -3
- ramifice/fields/choice_text_field.py +3 -3
- ramifice/fields/choice_text_mult_dyn_field.py +3 -3
- ramifice/fields/choice_text_mult_field.py +3 -3
- ramifice/fields/color_field.py +4 -4
- ramifice/fields/date_field.py +2 -2
- ramifice/fields/date_time_field.py +2 -2
- ramifice/fields/email_field.py +3 -3
- ramifice/fields/file_field.py +4 -4
- ramifice/fields/float_field.py +3 -3
- ramifice/fields/id_field.py +2 -2
- ramifice/fields/image_field.py +4 -4
- ramifice/fields/integer_field.py +3 -3
- ramifice/fields/ip_field.py +3 -3
- ramifice/fields/password_field.py +2 -2
- ramifice/fields/phone_field.py +3 -3
- ramifice/fields/slug_field.py +3 -3
- ramifice/fields/text_field.py +3 -3
- ramifice/fields/url_field.py +3 -3
- ramifice/models/__init__.py +1 -0
- ramifice/{decorators.py → models/decorator.py} +11 -13
- ramifice/{model.py → models/model.py} +4 -4
- ramifice/{pseudo_model.py → models/pseudo.py} +4 -4
- ramifice/paladins/check.py +11 -11
- ramifice/paladins/delete.py +10 -10
- ramifice/paladins/groups/choice_group.py +1 -1
- ramifice/paladins/groups/date_group.py +1 -1
- ramifice/paladins/groups/file_group.py +2 -2
- ramifice/paladins/groups/id_group.py +1 -1
- ramifice/paladins/groups/img_group.py +2 -2
- ramifice/paladins/groups/num_group.py +1 -1
- ramifice/paladins/groups/pass_group.py +2 -2
- ramifice/paladins/groups/slug_group.py +1 -1
- ramifice/paladins/groups/text_group.py +3 -3
- ramifice/paladins/password.py +10 -10
- ramifice/paladins/refrash.py +7 -7
- ramifice/paladins/save.py +16 -16
- ramifice/paladins/tools.py +1 -1
- ramifice/paladins/validation.py +4 -4
- ramifice/utils/__init__.py +1 -0
- ramifice/{store.py → utils/globals.py} +2 -4
- ramifice/{migration.py → utils/migration.py} +17 -17
- ramifice/utils/mixins/__init__.py +6 -0
- ramifice/{add_valid.py → utils/mixins/add_valid.py} +2 -2
- ramifice/{hooks.py → utils/mixins/hooks.py} +2 -2
- ramifice/utils/mixins/indexing.py +11 -0
- ramifice/{mixins.py → utils/mixins/json_converter.py} +2 -5
- ramifice/{tools.py → utils/tools.py} +1 -1
- ramifice/{types.py → utils/unit.py} +2 -9
- {ramifice-0.3.27.dist-info → ramifice-0.3.29.dist-info}/METADATA +5 -6
- ramifice-0.3.29.dist-info/RECORD +85 -0
- ramifice/indexing.py +0 -11
- ramifice-0.3.27.dist-info/RECORD +0 -82
- /ramifice/{errors.py → utils/errors.py} +0 -0
- /ramifice/{fixtures.py → utils/fixtures.py} +0 -0
- /ramifice/{translations.py → utils/translations.py} +0 -0
- {ramifice-0.3.27.dist-info → ramifice-0.3.29.dist-info}/WHEEL +0 -0
- {ramifice-0.3.27.dist-info → ramifice-0.3.29.dist-info}/licenses/LICENSE +0 -0
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Type of selective integer field with dynamic addition of elements.
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
|
-
from .. import
|
|
7
|
-
from ..mixins import JsonMixin
|
|
6
|
+
from ..utils import globals
|
|
7
|
+
from ..utils.mixins.json_converter import JsonMixin
|
|
8
8
|
from .general.choice_group import ChoiceGroup
|
|
9
9
|
from .general.field import Field
|
|
10
10
|
|
|
@@ -28,7 +28,7 @@ class ChoiceIntDynField(Field, ChoiceGroup, JsonMixin):
|
|
|
28
28
|
required: bool = False,
|
|
29
29
|
readonly: bool = False,
|
|
30
30
|
):
|
|
31
|
-
if
|
|
31
|
+
if globals.DEBUG:
|
|
32
32
|
if not isinstance(label, str):
|
|
33
33
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
|
34
34
|
if not isinstance(disabled, bool):
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Type of selective integer field with static of elements.
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
|
-
from .. import
|
|
7
|
-
from ..mixins import JsonMixin
|
|
6
|
+
from ..utils import globals
|
|
7
|
+
from ..utils.mixins.json_converter import JsonMixin
|
|
8
8
|
from .general.choice_group import ChoiceGroup
|
|
9
9
|
from .general.field import Field
|
|
10
10
|
|
|
@@ -51,7 +51,7 @@ class ChoiceIntField(Field, ChoiceGroup, JsonMixin):
|
|
|
51
51
|
self.default = default
|
|
52
52
|
self.choices = choices
|
|
53
53
|
|
|
54
|
-
if
|
|
54
|
+
if globals.DEBUG:
|
|
55
55
|
if choices is not None and not isinstance(choices, dict):
|
|
56
56
|
raise AssertionError("Parameter `choices` - Not а `dict` type!")
|
|
57
57
|
if default is not None and not isinstance(default, int):
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Type of selective integer field with dynamic addition of elements.
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
|
-
from .. import
|
|
7
|
-
from ..mixins import JsonMixin
|
|
6
|
+
from ..utils import globals
|
|
7
|
+
from ..utils.mixins.json_converter import JsonMixin
|
|
8
8
|
from .general.choice_group import ChoiceGroup
|
|
9
9
|
from .general.field import Field
|
|
10
10
|
|
|
@@ -27,7 +27,7 @@ class ChoiceIntMultDynField(Field, ChoiceGroup, JsonMixin):
|
|
|
27
27
|
required: bool = False,
|
|
28
28
|
readonly: bool = False,
|
|
29
29
|
):
|
|
30
|
-
if
|
|
30
|
+
if globals.DEBUG:
|
|
31
31
|
if not isinstance(label, str):
|
|
32
32
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
|
33
33
|
if not isinstance(disabled, bool):
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Type of selective integer field with static of elements.
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
|
-
from .. import
|
|
7
|
-
from ..mixins import JsonMixin
|
|
6
|
+
from ..utils import globals
|
|
7
|
+
from ..utils.mixins.json_converter import JsonMixin
|
|
8
8
|
from .general.choice_group import ChoiceGroup
|
|
9
9
|
from .general.field import Field
|
|
10
10
|
|
|
@@ -52,7 +52,7 @@ class ChoiceIntMultField(Field, ChoiceGroup, JsonMixin):
|
|
|
52
52
|
self.default = default
|
|
53
53
|
self.choices = choices
|
|
54
54
|
|
|
55
|
-
if
|
|
55
|
+
if globals.DEBUG:
|
|
56
56
|
if choices is not None:
|
|
57
57
|
if not isinstance(choices, dict):
|
|
58
58
|
raise AssertionError("Parameter `choices` - Not а `dict` type!")
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Type of selective text field with dynamic addition of elements.
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
|
-
from .. import
|
|
7
|
-
from ..mixins import JsonMixin
|
|
6
|
+
from ..utils import globals
|
|
7
|
+
from ..utils.mixins.json_converter import JsonMixin
|
|
8
8
|
from .general.choice_group import ChoiceGroup
|
|
9
9
|
from .general.field import Field
|
|
10
10
|
|
|
@@ -28,7 +28,7 @@ class ChoiceTextDynField(Field, ChoiceGroup, JsonMixin):
|
|
|
28
28
|
required: bool = False,
|
|
29
29
|
readonly: bool = False,
|
|
30
30
|
):
|
|
31
|
-
if
|
|
31
|
+
if globals.DEBUG:
|
|
32
32
|
if not isinstance(label, str):
|
|
33
33
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
|
34
34
|
if not isinstance(disabled, bool):
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Type of selective text field with static of elements.
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
|
-
from .. import
|
|
7
|
-
from ..mixins import JsonMixin
|
|
6
|
+
from ..utils import globals
|
|
7
|
+
from ..utils.mixins.json_converter import JsonMixin
|
|
8
8
|
from .general.choice_group import ChoiceGroup
|
|
9
9
|
from .general.field import Field
|
|
10
10
|
|
|
@@ -51,7 +51,7 @@ class ChoiceTextField(Field, ChoiceGroup, JsonMixin):
|
|
|
51
51
|
self.default = default
|
|
52
52
|
self.choices = choices
|
|
53
53
|
|
|
54
|
-
if
|
|
54
|
+
if globals.DEBUG:
|
|
55
55
|
if choices is not None and not isinstance(choices, dict):
|
|
56
56
|
raise AssertionError("Parameter `choices` - Not а `dict` type!")
|
|
57
57
|
if default is not None:
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Type of selective text field with dynamic addition of elements.
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
|
-
from .. import
|
|
7
|
-
from ..mixins import JsonMixin
|
|
6
|
+
from ..utils import globals
|
|
7
|
+
from ..utils.mixins.json_converter import JsonMixin
|
|
8
8
|
from .general.choice_group import ChoiceGroup
|
|
9
9
|
from .general.field import Field
|
|
10
10
|
|
|
@@ -27,7 +27,7 @@ class ChoiceTextMultDynField(Field, ChoiceGroup, JsonMixin):
|
|
|
27
27
|
required: bool = False,
|
|
28
28
|
readonly: bool = False,
|
|
29
29
|
):
|
|
30
|
-
if
|
|
30
|
+
if globals.DEBUG:
|
|
31
31
|
if not isinstance(label, str):
|
|
32
32
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
|
33
33
|
if not isinstance(disabled, bool):
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Type of selective text field with static of elements.
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
|
-
from .. import
|
|
7
|
-
from ..mixins import JsonMixin
|
|
6
|
+
from ..utils import globals
|
|
7
|
+
from ..utils.mixins.json_converter import JsonMixin
|
|
8
8
|
from .general.choice_group import ChoiceGroup
|
|
9
9
|
from .general.field import Field
|
|
10
10
|
|
|
@@ -52,7 +52,7 @@ class ChoiceTextMultField(Field, ChoiceGroup, JsonMixin):
|
|
|
52
52
|
self.default = default
|
|
53
53
|
self.choices = choices
|
|
54
54
|
|
|
55
|
-
if
|
|
55
|
+
if globals.DEBUG:
|
|
56
56
|
if choices is not None:
|
|
57
57
|
if not isinstance(choices, dict):
|
|
58
58
|
raise AssertionError("Parameter `choices` - Not а `dict` type!")
|
ramifice/fields/color_field.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Field of Model for enter color code."""
|
|
2
2
|
|
|
3
|
-
from .. import
|
|
4
|
-
from ..mixins import JsonMixin
|
|
3
|
+
from ..utils import globals
|
|
4
|
+
from ..utils.mixins.json_converter import JsonMixin
|
|
5
5
|
from .general.field import Field
|
|
6
6
|
from .general.text_group import TextGroup
|
|
7
7
|
|
|
@@ -31,7 +31,7 @@ class ColorField(Field, TextGroup, JsonMixin):
|
|
|
31
31
|
readonly: bool = False,
|
|
32
32
|
unique: bool = False,
|
|
33
33
|
):
|
|
34
|
-
if
|
|
34
|
+
if globals.DEBUG:
|
|
35
35
|
if default is not None:
|
|
36
36
|
if not isinstance(default, str):
|
|
37
37
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
|
@@ -39,7 +39,7 @@ class ColorField(Field, TextGroup, JsonMixin):
|
|
|
39
39
|
raise AssertionError(
|
|
40
40
|
"The `default` parameter should not contain an empty string!"
|
|
41
41
|
)
|
|
42
|
-
if
|
|
42
|
+
if globals.REGEX["color_code"].match(default) is None:
|
|
43
43
|
raise AssertionError("Parameter `default` - Not а color code!")
|
|
44
44
|
if not isinstance(label, str):
|
|
45
45
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
ramifice/fields/date_field.py
CHANGED
|
@@ -7,7 +7,7 @@ from typing import Any
|
|
|
7
7
|
from babel.dates import format_date
|
|
8
8
|
from dateutil.parser import parse
|
|
9
9
|
|
|
10
|
-
from .. import
|
|
10
|
+
from ..utils import globals, translations
|
|
11
11
|
from .general.date_group import DateGroup
|
|
12
12
|
from .general.field import Field
|
|
13
13
|
|
|
@@ -30,7 +30,7 @@ class DateField(Field, DateGroup):
|
|
|
30
30
|
max_date: datetime | None = None,
|
|
31
31
|
min_date: datetime | None = None,
|
|
32
32
|
):
|
|
33
|
-
if
|
|
33
|
+
if globals.DEBUG:
|
|
34
34
|
if max_date is not None:
|
|
35
35
|
if not isinstance(max_date, datetime):
|
|
36
36
|
raise AssertionError("Parameter `max_date` - Not а `str` type!")
|
|
@@ -7,7 +7,7 @@ from typing import Any
|
|
|
7
7
|
from babel.dates import format_datetime
|
|
8
8
|
from dateutil.parser import parse
|
|
9
9
|
|
|
10
|
-
from .. import
|
|
10
|
+
from ..utils import globals, translations
|
|
11
11
|
from .general.date_group import DateGroup
|
|
12
12
|
from .general.field import Field
|
|
13
13
|
|
|
@@ -30,7 +30,7 @@ class DateTimeField(Field, DateGroup):
|
|
|
30
30
|
max_date: datetime | None = None,
|
|
31
31
|
min_date: datetime | None = None,
|
|
32
32
|
):
|
|
33
|
-
if
|
|
33
|
+
if globals.DEBUG:
|
|
34
34
|
if max_date is not None:
|
|
35
35
|
if not isinstance(max_date, datetime):
|
|
36
36
|
raise AssertionError("Parameter `max_date` - Not а `str` type!")
|
ramifice/fields/email_field.py
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
from email_validator import EmailNotValidError, validate_email
|
|
4
4
|
|
|
5
|
-
from .. import
|
|
6
|
-
from ..mixins import JsonMixin
|
|
5
|
+
from ..utils import globals
|
|
6
|
+
from ..utils.mixins.json_converter import JsonMixin
|
|
7
7
|
from .general.field import Field
|
|
8
8
|
from .general.text_group import TextGroup
|
|
9
9
|
|
|
@@ -25,7 +25,7 @@ class EmailField(Field, TextGroup, JsonMixin):
|
|
|
25
25
|
readonly: bool = False,
|
|
26
26
|
unique: bool = False,
|
|
27
27
|
):
|
|
28
|
-
if
|
|
28
|
+
if globals.DEBUG:
|
|
29
29
|
if default is not None:
|
|
30
30
|
if not isinstance(default, str):
|
|
31
31
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
ramifice/fields/file_field.py
CHANGED
|
@@ -8,9 +8,9 @@ from datetime import date
|
|
|
8
8
|
from pathlib import Path
|
|
9
9
|
from typing import Any
|
|
10
10
|
|
|
11
|
-
from .. import
|
|
12
|
-
from ..errors import FileHasNoExtensionError
|
|
13
|
-
from ..mixins import JsonMixin
|
|
11
|
+
from ..utils import globals
|
|
12
|
+
from ..utils.errors import FileHasNoExtensionError
|
|
13
|
+
from ..utils.mixins.json_converter import JsonMixin
|
|
14
14
|
from .general.field import Field
|
|
15
15
|
from .general.file_group import FileGroup
|
|
16
16
|
|
|
@@ -34,7 +34,7 @@ class FileField(Field, FileGroup, JsonMixin):
|
|
|
34
34
|
target_dir: str = "files",
|
|
35
35
|
accept: str = "",
|
|
36
36
|
):
|
|
37
|
-
if
|
|
37
|
+
if globals.DEBUG:
|
|
38
38
|
if default is not None:
|
|
39
39
|
if not isinstance(default, str):
|
|
40
40
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
ramifice/fields/float_field.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Field of Model for enter (float) number."""
|
|
2
2
|
|
|
3
|
-
from .. import
|
|
4
|
-
from ..mixins import JsonMixin
|
|
3
|
+
from ..utils import globals
|
|
4
|
+
from ..utils.mixins.json_converter import JsonMixin
|
|
5
5
|
from .general.field import Field
|
|
6
6
|
from .general.number_group import NumberGroup
|
|
7
7
|
|
|
@@ -27,7 +27,7 @@ class FloatField(Field, NumberGroup, JsonMixin):
|
|
|
27
27
|
step: float = 1.0,
|
|
28
28
|
input_type: str = "number", # number | range
|
|
29
29
|
):
|
|
30
|
-
if
|
|
30
|
+
if globals.DEBUG:
|
|
31
31
|
if input_type not in ["number", "range"]:
|
|
32
32
|
raise AssertionError(
|
|
33
33
|
"Parameter `input_type` - Invalid input type! "
|
ramifice/fields/id_field.py
CHANGED
|
@@ -5,7 +5,7 @@ from typing import Any
|
|
|
5
5
|
|
|
6
6
|
from bson.objectid import ObjectId
|
|
7
7
|
|
|
8
|
-
from .. import
|
|
8
|
+
from ..utils import globals
|
|
9
9
|
from .general.field import Field
|
|
10
10
|
|
|
11
11
|
|
|
@@ -33,7 +33,7 @@ class IDField(Field):
|
|
|
33
33
|
readonly: bool = False,
|
|
34
34
|
unique: bool = False,
|
|
35
35
|
):
|
|
36
|
-
if
|
|
36
|
+
if globals.DEBUG:
|
|
37
37
|
if not isinstance(label, str):
|
|
38
38
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
|
39
39
|
if not isinstance(disabled, bool):
|
ramifice/fields/image_field.py
CHANGED
|
@@ -10,9 +10,9 @@ from typing import Any
|
|
|
10
10
|
|
|
11
11
|
from PIL import Image
|
|
12
12
|
|
|
13
|
-
from .. import
|
|
14
|
-
from ..errors import FileHasNoExtensionError
|
|
15
|
-
from ..mixins import JsonMixin
|
|
13
|
+
from ..utils import globals
|
|
14
|
+
from ..utils.errors import FileHasNoExtensionError
|
|
15
|
+
from ..utils.mixins.json_converter import JsonMixin
|
|
16
16
|
from .general.field import Field
|
|
17
17
|
from .general.file_group import FileGroup
|
|
18
18
|
|
|
@@ -41,7 +41,7 @@ class ImageField(Field, FileGroup, JsonMixin):
|
|
|
41
41
|
# True - high quality and low performance for thumbnails.
|
|
42
42
|
high_quality: bool = False,
|
|
43
43
|
):
|
|
44
|
-
if
|
|
44
|
+
if globals.DEBUG:
|
|
45
45
|
if default is not None:
|
|
46
46
|
if not isinstance(default, str):
|
|
47
47
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
ramifice/fields/integer_field.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Field of Model for enter (int) number."""
|
|
2
2
|
|
|
3
|
-
from .. import
|
|
4
|
-
from ..mixins import JsonMixin
|
|
3
|
+
from ..utils import globals
|
|
4
|
+
from ..utils.mixins.json_converter import JsonMixin
|
|
5
5
|
from .general.field import Field
|
|
6
6
|
from .general.number_group import NumberGroup
|
|
7
7
|
|
|
@@ -27,7 +27,7 @@ class IntegerField(Field, NumberGroup, JsonMixin):
|
|
|
27
27
|
step: int = 1,
|
|
28
28
|
input_type: str = "number", # number | range
|
|
29
29
|
):
|
|
30
|
-
if
|
|
30
|
+
if globals.DEBUG:
|
|
31
31
|
if input_type not in ["number", "range"]:
|
|
32
32
|
raise AssertionError(
|
|
33
33
|
"Parameter `input_type` - Invalid input type! "
|
ramifice/fields/ip_field.py
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import ipaddress
|
|
4
4
|
|
|
5
|
-
from .. import
|
|
6
|
-
from ..mixins import JsonMixin
|
|
5
|
+
from ..utils import globals
|
|
6
|
+
from ..utils.mixins.json_converter import JsonMixin
|
|
7
7
|
from .general.field import Field
|
|
8
8
|
from .general.text_group import TextGroup
|
|
9
9
|
|
|
@@ -25,7 +25,7 @@ class IPField(Field, TextGroup, JsonMixin):
|
|
|
25
25
|
readonly: bool = False,
|
|
26
26
|
unique: bool = False,
|
|
27
27
|
):
|
|
28
|
-
if
|
|
28
|
+
if globals.DEBUG:
|
|
29
29
|
if default is not None:
|
|
30
30
|
if not isinstance(default, str):
|
|
31
31
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import json
|
|
4
4
|
from typing import Any
|
|
5
5
|
|
|
6
|
-
from .. import
|
|
6
|
+
from ..utils import globals
|
|
7
7
|
from .general.field import Field
|
|
8
8
|
|
|
9
9
|
|
|
@@ -26,7 +26,7 @@ class PasswordField(Field):
|
|
|
26
26
|
placeholder: str = "",
|
|
27
27
|
required: bool = False,
|
|
28
28
|
):
|
|
29
|
-
if
|
|
29
|
+
if globals.DEBUG:
|
|
30
30
|
if not isinstance(label, str):
|
|
31
31
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
|
32
32
|
if not isinstance(hide, bool):
|
ramifice/fields/phone_field.py
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import phonenumbers
|
|
4
4
|
|
|
5
|
-
from .. import
|
|
6
|
-
from ..mixins import JsonMixin
|
|
5
|
+
from ..utils import globals
|
|
6
|
+
from ..utils.mixins.json_converter import JsonMixin
|
|
7
7
|
from .general.field import Field
|
|
8
8
|
from .general.text_group import TextGroup
|
|
9
9
|
|
|
@@ -28,7 +28,7 @@ class PhoneField(Field, TextGroup, JsonMixin):
|
|
|
28
28
|
readonly: bool = False,
|
|
29
29
|
unique: bool = False,
|
|
30
30
|
):
|
|
31
|
-
if
|
|
31
|
+
if globals.DEBUG:
|
|
32
32
|
if default is not None:
|
|
33
33
|
if not isinstance(default, str):
|
|
34
34
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
ramifice/fields/slug_field.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Field of Model for automatic generation of string `slug`."""
|
|
2
2
|
|
|
3
|
-
from .. import
|
|
4
|
-
from ..mixins import JsonMixin
|
|
3
|
+
from ..utils import globals
|
|
4
|
+
from ..utils.mixins.json_converter import JsonMixin
|
|
5
5
|
from .general.field import Field
|
|
6
6
|
from .general.text_group import TextGroup
|
|
7
7
|
|
|
@@ -24,7 +24,7 @@ class SlugField(Field, TextGroup, JsonMixin):
|
|
|
24
24
|
readonly: bool = False,
|
|
25
25
|
slug_sources: list[str] = ["_id"],
|
|
26
26
|
):
|
|
27
|
-
if
|
|
27
|
+
if globals.DEBUG:
|
|
28
28
|
if not isinstance(label, str):
|
|
29
29
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
|
30
30
|
if not isinstance(disabled, bool):
|
ramifice/fields/text_field.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Field of Model for enter text."""
|
|
2
2
|
|
|
3
|
-
from .. import
|
|
4
|
-
from ..mixins import JsonMixin
|
|
3
|
+
from ..utils import globals
|
|
4
|
+
from ..utils.mixins.json_converter import JsonMixin
|
|
5
5
|
from .general.field import Field
|
|
6
6
|
from .general.text_group import TextGroup
|
|
7
7
|
|
|
@@ -26,7 +26,7 @@ class TextField(Field, TextGroup, JsonMixin):
|
|
|
26
26
|
unique: bool = False,
|
|
27
27
|
maxlength: int = 256,
|
|
28
28
|
):
|
|
29
|
-
if
|
|
29
|
+
if globals.DEBUG:
|
|
30
30
|
if not isinstance(maxlength, int):
|
|
31
31
|
raise AssertionError("Parameter `maxlength` - Not а `int` type!")
|
|
32
32
|
if default is not None:
|
ramifice/fields/url_field.py
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
from urllib.parse import urlparse
|
|
4
4
|
|
|
5
|
-
from .. import
|
|
6
|
-
from ..mixins import JsonMixin
|
|
5
|
+
from ..utils import globals
|
|
6
|
+
from ..utils.mixins.json_converter import JsonMixin
|
|
7
7
|
from .general.field import Field
|
|
8
8
|
from .general.text_group import TextGroup
|
|
9
9
|
|
|
@@ -39,7 +39,7 @@ class URLField(Field, TextGroup, JsonMixin):
|
|
|
39
39
|
readonly: bool = False,
|
|
40
40
|
unique: bool = False,
|
|
41
41
|
):
|
|
42
|
-
if
|
|
42
|
+
if globals.DEBUG:
|
|
43
43
|
if default is not None:
|
|
44
44
|
if not isinstance(default, str):
|
|
45
45
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Models."""
|
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""Decorator for converting Python classes into Ramifice models."""
|
|
2
2
|
|
|
3
3
|
import os
|
|
4
4
|
from typing import Any
|
|
5
5
|
|
|
6
|
-
from
|
|
7
|
-
from
|
|
8
|
-
from
|
|
9
|
-
from .errors import DoesNotMatchRegexError, PanicError
|
|
10
|
-
from .
|
|
11
|
-
from .hooks import HooksMixin
|
|
12
|
-
from .indexing import IndexMixin
|
|
6
|
+
from ..commons import QCommonsMixin
|
|
7
|
+
from ..fields import DateTimeField, IDField
|
|
8
|
+
from ..paladins import CheckMixin, QPaladinsMixin, ValidationMixin
|
|
9
|
+
from ..utils.errors import DoesNotMatchRegexError, PanicError
|
|
10
|
+
from ..utils.mixins.add_valid import AddValidMixin
|
|
11
|
+
from ..utils.mixins.hooks import HooksMixin
|
|
12
|
+
from ..utils.mixins.indexing import IndexMixin
|
|
13
|
+
from ..utils.globals import REGEX
|
|
13
14
|
from .model import Model
|
|
14
|
-
from .
|
|
15
|
-
from .pseudo_model import PseudoModel
|
|
16
|
-
from .store import REGEX
|
|
15
|
+
from .pseudo import PseudoModel
|
|
17
16
|
|
|
18
17
|
|
|
19
|
-
# Decorator for converting into a Model.
|
|
20
18
|
def model(
|
|
21
19
|
service_name: str,
|
|
22
20
|
fixture_name: str | None = None,
|
|
@@ -26,7 +24,7 @@ def model(
|
|
|
26
24
|
is_update_doc: bool = True,
|
|
27
25
|
is_delete_doc: bool = True,
|
|
28
26
|
) -> Any:
|
|
29
|
-
"""Decorator for converting into
|
|
27
|
+
"""Decorator for converting Python Classe into Ramifice Model."""
|
|
30
28
|
if not isinstance(service_name, str):
|
|
31
29
|
raise AssertionError("Parameter `service_name` - Must be `str` type!")
|
|
32
30
|
if not isinstance(fixture_name, (str, type(None))):
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""For converting Python classes into Ramifice
|
|
1
|
+
"""For converting Python classes into Ramifice models."""
|
|
2
2
|
|
|
3
3
|
import json
|
|
4
4
|
from abc import ABCMeta, abstractmethod
|
|
@@ -8,12 +8,12 @@ from babel.dates import format_date, format_datetime
|
|
|
8
8
|
from bson.objectid import ObjectId
|
|
9
9
|
from dateutil.parser import parse
|
|
10
10
|
|
|
11
|
-
from
|
|
12
|
-
from
|
|
11
|
+
from ..fields import DateTimeField, IDField
|
|
12
|
+
from ..utils import translations
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
class Model(metaclass=ABCMeta):
|
|
16
|
-
"""
|
|
16
|
+
"""Converting Python Class into Ramifice Model."""
|
|
17
17
|
|
|
18
18
|
META: dict[str, Any] = {}
|
|
19
19
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""For converting Python classes into Ramifice
|
|
1
|
+
"""For converting Python classes into Ramifice models."""
|
|
2
2
|
|
|
3
3
|
import json
|
|
4
4
|
import os
|
|
@@ -10,12 +10,12 @@ from babel.dates import format_date, format_datetime
|
|
|
10
10
|
from bson.objectid import ObjectId
|
|
11
11
|
from dateutil.parser import parse
|
|
12
12
|
|
|
13
|
-
from
|
|
14
|
-
from .errors import PanicError
|
|
13
|
+
from ..utils import translations
|
|
14
|
+
from ..utils.errors import PanicError
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
class PseudoModel(metaclass=ABCMeta):
|
|
18
|
-
"""
|
|
18
|
+
"""Convert the Python Class into a pseudo Model Ramifice.
|
|
19
19
|
|
|
20
20
|
Used for a Model that do not migrate into the database.
|
|
21
21
|
"""
|
ramifice/paladins/check.py
CHANGED
|
@@ -7,9 +7,9 @@ from typing import Any
|
|
|
7
7
|
from bson.objectid import ObjectId
|
|
8
8
|
from pymongo.asynchronous.collection import AsyncCollection
|
|
9
9
|
|
|
10
|
-
from .. import
|
|
11
|
-
from ..errors import PanicError
|
|
12
|
-
from .groups import (
|
|
10
|
+
from ..utils import globals
|
|
11
|
+
from ..utils.errors import PanicError
|
|
12
|
+
from .groups import (
|
|
13
13
|
BoolGroupMixin,
|
|
14
14
|
ChoiceGroupMixin,
|
|
15
15
|
DateGroupMixin,
|
|
@@ -45,11 +45,11 @@ class CheckMixin(
|
|
|
45
45
|
It is also used to verify Models that do not migrate to the database.
|
|
46
46
|
"""
|
|
47
47
|
cls_model = self.__class__
|
|
48
|
-
is_migrate_model: bool = cls_model.META["is_migrate_model"]
|
|
48
|
+
is_migrate_model: bool = cls_model.META["is_migrate_model"]
|
|
49
49
|
|
|
50
50
|
if not is_migrate_model and is_save:
|
|
51
51
|
msg = (
|
|
52
|
-
f"Model: `{self.full_model_name()}` > "
|
|
52
|
+
f"Model: `{self.full_model_name()}` > "
|
|
53
53
|
+ "Method: `check` => "
|
|
54
54
|
+ "For a non -migrating Model, the `is_save` parameter must be equal to` False` !"
|
|
55
55
|
)
|
|
@@ -59,20 +59,20 @@ class CheckMixin(
|
|
|
59
59
|
is_update: bool = False
|
|
60
60
|
if is_migrate_model:
|
|
61
61
|
# Get the document ID.
|
|
62
|
-
doc_id = self._id.value
|
|
62
|
+
doc_id = self._id.value
|
|
63
63
|
# Does the document exist in the database?
|
|
64
64
|
is_update = doc_id is not None
|
|
65
65
|
# Create an identifier for a new document.
|
|
66
66
|
if is_save and not is_update:
|
|
67
67
|
doc_id = ObjectId()
|
|
68
|
-
self._id.value = doc_id
|
|
68
|
+
self._id.value = doc_id
|
|
69
69
|
|
|
70
70
|
result_map: dict[str, Any] = {}
|
|
71
71
|
# Errors from additional validation of fields.
|
|
72
|
-
error_map: dict[str, str] = await self.add_validation() or {}
|
|
72
|
+
error_map: dict[str, str] = await self.add_validation() or {}
|
|
73
73
|
# Get Model collection.
|
|
74
74
|
if collection is None:
|
|
75
|
-
collection =
|
|
75
|
+
collection = globals.MONGO_DATABASE[cls_model.META["collection_name"]]
|
|
76
76
|
# Create params for *_group methods.
|
|
77
77
|
params: dict[str, Any] = {
|
|
78
78
|
"doc_id": doc_id,
|
|
@@ -82,7 +82,7 @@ class CheckMixin(
|
|
|
82
82
|
"result_map": result_map, # Data to save or update to the database.
|
|
83
83
|
"collection": collection,
|
|
84
84
|
"field_data": None,
|
|
85
|
-
"full_model_name": cls_model.META["full_model_name"],
|
|
85
|
+
"full_model_name": cls_model.META["full_model_name"],
|
|
86
86
|
"is_migrate_model": is_migrate_model,
|
|
87
87
|
}
|
|
88
88
|
|
|
@@ -126,7 +126,7 @@ class CheckMixin(
|
|
|
126
126
|
if params["is_error_symptom"]:
|
|
127
127
|
# Reset the ObjectId for a new document.
|
|
128
128
|
if not is_update:
|
|
129
|
-
self._id.value = None
|
|
129
|
+
self._id.value = None
|
|
130
130
|
# Delete orphaned files.
|
|
131
131
|
curr_doc: dict[str, Any] | None = (
|
|
132
132
|
await collection.find_one({"_id": doc_id}) if is_update else None
|