ramifice 0.8.11__py3-none-any.whl → 0.8.13__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 +16 -1
- ramifice/commons/__init__.py +2 -2
- ramifice/commons/general.py +11 -11
- ramifice/commons/indexes.py +8 -8
- ramifice/commons/many.py +10 -6
- ramifice/commons/one.py +13 -8
- ramifice/commons/tools.py +4 -4
- ramifice/commons/unit_manager.py +15 -5
- ramifice/fields/__init__.py +1 -1
- ramifice/fields/bool_field.py +26 -18
- ramifice/fields/choice_float_dyn_field.py +29 -21
- ramifice/fields/choice_float_field.py +41 -33
- ramifice/fields/choice_float_mult_dyn_field.py +29 -21
- ramifice/fields/choice_float_mult_field.py +48 -40
- ramifice/fields/choice_int_dyn_field.py +29 -21
- ramifice/fields/choice_int_field.py +41 -33
- ramifice/fields/choice_int_mult_dyn_field.py +29 -21
- ramifice/fields/choice_int_mult_field.py +48 -40
- ramifice/fields/choice_text_dyn_field.py +29 -21
- ramifice/fields/choice_text_field.py +47 -39
- ramifice/fields/choice_text_mult_dyn_field.py +29 -21
- ramifice/fields/choice_text_mult_field.py +48 -40
- ramifice/fields/color_field.py +40 -32
- ramifice/fields/date_field.py +49 -40
- ramifice/fields/date_time_field.py +49 -40
- ramifice/fields/email_field.py +42 -34
- ramifice/fields/file_field.py +45 -35
- ramifice/fields/float_field.py +56 -47
- ramifice/fields/general/__init__.py +1 -1
- ramifice/fields/general/choice_group.py +2 -2
- ramifice/fields/general/date_group.py +2 -2
- ramifice/fields/general/field.py +2 -2
- ramifice/fields/general/file_group.py +2 -2
- ramifice/fields/general/number_group.py +2 -2
- ramifice/fields/general/text_group.py +3 -3
- ramifice/fields/id_field.py +35 -28
- ramifice/fields/image_field.py +67 -57
- ramifice/fields/integer_field.py +56 -47
- ramifice/fields/ip_field.py +41 -34
- ramifice/fields/password_field.py +29 -22
- ramifice/fields/phone_field.py +44 -36
- ramifice/fields/slug_field.py +30 -22
- ramifice/fields/text_field.py +43 -35
- ramifice/fields/url_field.py +40 -33
- ramifice/models/__init__.py +1 -1
- ramifice/models/decorator.py +33 -11
- ramifice/models/model.py +16 -16
- ramifice/paladins/__init__.py +2 -2
- ramifice/paladins/check.py +8 -3
- ramifice/paladins/delete.py +9 -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 +8 -3
- ramifice/paladins/groups/text_group.py +3 -3
- ramifice/paladins/password.py +11 -4
- ramifice/paladins/refrash.py +7 -3
- ramifice/paladins/save.py +9 -3
- ramifice/paladins/tools.py +11 -6
- ramifice/paladins/validation.py +4 -4
- ramifice/utils/__init__.py +1 -1
- ramifice/utils/constants.py +1 -1
- ramifice/utils/errors.py +7 -7
- ramifice/utils/fixtures.py +7 -2
- ramifice/utils/migration.py +18 -9
- ramifice/utils/mixins/__init__.py +1 -1
- ramifice/utils/mixins/add_valid.py +3 -3
- ramifice/utils/mixins/hooks.py +8 -8
- ramifice/utils/mixins/indexing.py +3 -3
- ramifice/utils/mixins/json_converter.py +6 -6
- ramifice/utils/tools.py +12 -12
- ramifice/utils/translations.py +24 -8
- ramifice/utils/unit.py +8 -3
- {ramifice-0.8.11.dist-info → ramifice-0.8.13.dist-info}/METADATA +9 -5
- ramifice-0.8.13.dist-info/RECORD +84 -0
- ramifice-0.8.11.dist-info/RECORD +0 -84
- {ramifice-0.8.11.dist-info → ramifice-0.8.13.dist-info}/WHEEL +0 -0
- {ramifice-0.8.11.dist-info → ramifice-0.8.13.dist-info}/licenses/LICENSE +0 -0
@@ -1,18 +1,22 @@
|
|
1
|
-
"""Field of Model.
|
1
|
+
"""Ramifice - Field of Model.
|
2
2
|
|
3
3
|
Type of selective integer field with static of elements.
|
4
4
|
"""
|
5
5
|
|
6
6
|
__all__ = ("ChoiceIntMultField",)
|
7
7
|
|
8
|
+
import logging
|
9
|
+
|
8
10
|
from ramifice.fields.general.choice_group import ChoiceGroup
|
9
11
|
from ramifice.fields.general.field import Field
|
10
12
|
from ramifice.utils import constants
|
11
13
|
from ramifice.utils.mixins.json_converter import JsonMixin
|
12
14
|
|
15
|
+
logger = logging.getLogger(__name__)
|
16
|
+
|
13
17
|
|
14
18
|
class ChoiceIntMultField(Field, ChoiceGroup, JsonMixin):
|
15
|
-
"""Field of Model.
|
19
|
+
"""Ramifice - Field of Model.
|
16
20
|
|
17
21
|
Type of selective integer field with static of elements.
|
18
22
|
With multiple choice.
|
@@ -55,46 +59,50 @@ class ChoiceIntMultField(Field, ChoiceGroup, JsonMixin):
|
|
55
59
|
self.choices = choices
|
56
60
|
|
57
61
|
if constants.DEBUG:
|
58
|
-
|
59
|
-
if not
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
if not
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
62
|
+
try:
|
63
|
+
if choices is not None:
|
64
|
+
if not isinstance(choices, list):
|
65
|
+
raise AssertionError("Parameter `choices` - Not а `list` type!")
|
66
|
+
if len(choices) == 0:
|
67
|
+
raise AssertionError(
|
68
|
+
"The `choices` parameter should not contain an empty list!"
|
69
|
+
)
|
70
|
+
if default is not None:
|
71
|
+
if not isinstance(default, list):
|
72
|
+
raise AssertionError("Parameter `default` - Not а `list` type!")
|
73
|
+
if len(default) == 0:
|
74
|
+
raise AssertionError(
|
75
|
+
"The `default` parameter should not contain an empty list!"
|
76
|
+
)
|
77
|
+
if choices is not None and not self.has_value():
|
78
|
+
raise AssertionError(
|
79
|
+
"Parameter `default` does not coincide with "
|
80
|
+
+ "list of permissive values in `choicees`."
|
81
|
+
)
|
82
|
+
if not isinstance(label, str):
|
83
|
+
raise AssertionError("Parameter `default` - Not а `str` type!")
|
84
|
+
if not isinstance(disabled, bool):
|
85
|
+
raise AssertionError("Parameter `disabled` - Not а `bool` type!")
|
86
|
+
if not isinstance(hide, bool):
|
87
|
+
raise AssertionError("Parameter `hide` - Not а `bool` type!")
|
88
|
+
if not isinstance(ignored, bool):
|
89
|
+
raise AssertionError("Parameter `ignored` - Not а `bool` type!")
|
90
|
+
if not isinstance(ignored, bool):
|
91
|
+
raise AssertionError("Parameter `ignored` - Not а `bool` type!")
|
92
|
+
if not isinstance(hint, str):
|
93
|
+
raise AssertionError("Parameter `hint` - Not а `str` type!")
|
94
|
+
if warning is not None and not isinstance(warning, list):
|
95
|
+
raise AssertionError("Parameter `warning` - Not а `list` type!")
|
96
|
+
if not isinstance(required, bool):
|
97
|
+
raise AssertionError("Parameter `required` - Not а `bool` type!")
|
98
|
+
if not isinstance(readonly, bool):
|
99
|
+
raise AssertionError("Parameter `readonly` - Not а `bool` type!")
|
100
|
+
except AssertionError as err:
|
101
|
+
logger.error(str(err))
|
102
|
+
raise err
|
95
103
|
|
96
104
|
def has_value(self, is_migrate: bool = False) -> bool:
|
97
|
-
"""Does the field value match the possible options in choices."""
|
105
|
+
"""Ramifice - Does the field value match the possible options in choices."""
|
98
106
|
value = self.value
|
99
107
|
if value is None:
|
100
108
|
value = self.default
|
@@ -1,18 +1,22 @@
|
|
1
|
-
"""Field of Model.
|
1
|
+
"""Ramifice - Field of Model.
|
2
2
|
|
3
3
|
Type of selective text field with dynamic addition of elements.
|
4
4
|
"""
|
5
5
|
|
6
6
|
__all__ = ("ChoiceTextDynField",)
|
7
7
|
|
8
|
+
import logging
|
9
|
+
|
8
10
|
from ramifice.fields.general.choice_group import ChoiceGroup
|
9
11
|
from ramifice.fields.general.field import Field
|
10
12
|
from ramifice.utils import constants
|
11
13
|
from ramifice.utils.mixins.json_converter import JsonMixin
|
12
14
|
|
15
|
+
logger = logging.getLogger(__name__)
|
16
|
+
|
13
17
|
|
14
18
|
class ChoiceTextDynField(Field, ChoiceGroup, JsonMixin):
|
15
|
-
"""Field of Model.
|
19
|
+
"""Ramifice - Field of Model.
|
16
20
|
|
17
21
|
Type of selective text field with dynamic addition of elements.
|
18
22
|
For simulate relationship Many-to-One.
|
@@ -31,24 +35,28 @@ class ChoiceTextDynField(Field, ChoiceGroup, JsonMixin):
|
|
31
35
|
readonly: bool = False,
|
32
36
|
):
|
33
37
|
if constants.DEBUG:
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
38
|
+
try:
|
39
|
+
if not isinstance(label, str):
|
40
|
+
raise AssertionError("Parameter `default` - Not а `str` type!")
|
41
|
+
if not isinstance(disabled, bool):
|
42
|
+
raise AssertionError("Parameter `disabled` - Not а `bool` type!")
|
43
|
+
if not isinstance(hide, bool):
|
44
|
+
raise AssertionError("Parameter `hide` - Not а `bool` type!")
|
45
|
+
if not isinstance(ignored, bool):
|
46
|
+
raise AssertionError("Parameter `ignored` - Not а `bool` type!")
|
47
|
+
if not isinstance(ignored, bool):
|
48
|
+
raise AssertionError("Parameter `ignored` - Not а `bool` type!")
|
49
|
+
if not isinstance(hint, str):
|
50
|
+
raise AssertionError("Parameter `hint` - Not а `str` type!")
|
51
|
+
if warning is not None and not isinstance(warning, list):
|
52
|
+
raise AssertionError("Parameter `warning` - Not а `list` type!")
|
53
|
+
if not isinstance(required, bool):
|
54
|
+
raise AssertionError("Parameter `required` - Not а `bool` type!")
|
55
|
+
if not isinstance(readonly, bool):
|
56
|
+
raise AssertionError("Parameter `readonly` - Not а `bool` type!")
|
57
|
+
except AssertionError as err:
|
58
|
+
logger.error(str(err))
|
59
|
+
raise err
|
52
60
|
|
53
61
|
Field.__init__(
|
54
62
|
self,
|
@@ -72,7 +80,7 @@ class ChoiceTextDynField(Field, ChoiceGroup, JsonMixin):
|
|
72
80
|
self.choices: list[list[str]] | None = None
|
73
81
|
|
74
82
|
def has_value(self, is_migrate: bool = False) -> bool:
|
75
|
-
"""Does the field value match the possible options in choices."""
|
83
|
+
"""Ramifice - Does the field value match the possible options in choices."""
|
76
84
|
if is_migrate:
|
77
85
|
return True
|
78
86
|
value = self.value
|
@@ -1,18 +1,22 @@
|
|
1
|
-
"""Field of Model.
|
1
|
+
"""Ramifice - Field of Model.
|
2
2
|
|
3
3
|
Type of selective text field with static of elements.
|
4
4
|
"""
|
5
5
|
|
6
6
|
__all__ = ("ChoiceTextField",)
|
7
7
|
|
8
|
+
import logging
|
9
|
+
|
8
10
|
from ramifice.fields.general.choice_group import ChoiceGroup
|
9
11
|
from ramifice.fields.general.field import Field
|
10
12
|
from ramifice.utils import constants
|
11
13
|
from ramifice.utils.mixins.json_converter import JsonMixin
|
12
14
|
|
15
|
+
logger = logging.getLogger(__name__)
|
16
|
+
|
13
17
|
|
14
18
|
class ChoiceTextField(Field, ChoiceGroup, JsonMixin):
|
15
|
-
"""Field of Model.
|
19
|
+
"""Ramifice - Field of Model.
|
16
20
|
|
17
21
|
Type of selective text field with static of elements.
|
18
22
|
With a single choice.
|
@@ -54,46 +58,50 @@ class ChoiceTextField(Field, ChoiceGroup, JsonMixin):
|
|
54
58
|
self.choices = choices
|
55
59
|
|
56
60
|
if constants.DEBUG:
|
57
|
-
|
58
|
-
if not
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
if not
|
61
|
+
try:
|
62
|
+
if choices is not None:
|
63
|
+
if not isinstance(choices, list):
|
64
|
+
raise AssertionError("Parameter `choices` - Not а `list` type!")
|
65
|
+
if len(choices) == 0:
|
66
|
+
raise AssertionError(
|
67
|
+
"The `choices` parameter should not contain an empty list!"
|
68
|
+
)
|
69
|
+
if default is not None:
|
70
|
+
if not isinstance(default, str):
|
71
|
+
raise AssertionError("Parameter `default` - Not а `str` type!")
|
72
|
+
if len(default) == 0:
|
73
|
+
raise AssertionError(
|
74
|
+
"The `default` parameter should not contain an empty string!"
|
75
|
+
)
|
76
|
+
if choices is not None and not self.has_value():
|
77
|
+
raise AssertionError(
|
78
|
+
"Parameter `default` does not coincide with "
|
79
|
+
+ "list of permissive values in `choicees`."
|
80
|
+
)
|
81
|
+
if not isinstance(label, str):
|
66
82
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
67
|
-
if
|
68
|
-
raise AssertionError(
|
69
|
-
|
70
|
-
)
|
71
|
-
if
|
72
|
-
raise AssertionError(
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
raise
|
86
|
-
if not isinstance(hint, str):
|
87
|
-
raise AssertionError("Parameter `hint` - Not а `str` type!")
|
88
|
-
if warning is not None and not isinstance(warning, list):
|
89
|
-
raise AssertionError("Parameter `warning` - Not а `list` type!")
|
90
|
-
if not isinstance(required, bool):
|
91
|
-
raise AssertionError("Parameter `required` - Not а `bool` type!")
|
92
|
-
if not isinstance(readonly, bool):
|
93
|
-
raise AssertionError("Parameter `readonly` - Not а `bool` type!")
|
83
|
+
if not isinstance(disabled, bool):
|
84
|
+
raise AssertionError("Parameter `disabled` - Not а `bool` type!")
|
85
|
+
if not isinstance(hide, bool):
|
86
|
+
raise AssertionError("Parameter `hide` - Not а `bool` type!")
|
87
|
+
if not isinstance(ignored, bool):
|
88
|
+
raise AssertionError("Parameter `ignored` - Not а `bool` type!")
|
89
|
+
if not isinstance(ignored, bool):
|
90
|
+
raise AssertionError("Parameter `ignored` - Not а `bool` type!")
|
91
|
+
if not isinstance(hint, str):
|
92
|
+
raise AssertionError("Parameter `hint` - Not а `str` type!")
|
93
|
+
if warning is not None and not isinstance(warning, list):
|
94
|
+
raise AssertionError("Parameter `warning` - Not а `list` type!")
|
95
|
+
if not isinstance(required, bool):
|
96
|
+
raise AssertionError("Parameter `required` - Not а `bool` type!")
|
97
|
+
if not isinstance(readonly, bool):
|
98
|
+
raise AssertionError("Parameter `readonly` - Not а `bool` type!")
|
99
|
+
except AssertionError as err:
|
100
|
+
logger.error(str(err))
|
101
|
+
raise err
|
94
102
|
|
95
103
|
def has_value(self, is_migrate: bool = False) -> bool:
|
96
|
-
"""Does the field value match the possible options in choices."""
|
104
|
+
"""Ramifice - Does the field value match the possible options in choices."""
|
97
105
|
value = self.value
|
98
106
|
if value is None:
|
99
107
|
value = self.default
|
@@ -1,18 +1,22 @@
|
|
1
|
-
"""Field of Model.
|
1
|
+
"""Ramifice - Field of Model.
|
2
2
|
|
3
3
|
Type of selective text field with dynamic addition of elements.
|
4
4
|
"""
|
5
5
|
|
6
6
|
__all__ = ("ChoiceTextMultDynField",)
|
7
7
|
|
8
|
+
import logging
|
9
|
+
|
8
10
|
from ramifice.fields.general.choice_group import ChoiceGroup
|
9
11
|
from ramifice.fields.general.field import Field
|
10
12
|
from ramifice.utils import constants
|
11
13
|
from ramifice.utils.mixins.json_converter import JsonMixin
|
12
14
|
|
15
|
+
logger = logging.getLogger(__name__)
|
16
|
+
|
13
17
|
|
14
18
|
class ChoiceTextMultDynField(Field, ChoiceGroup, JsonMixin):
|
15
|
-
"""Field of Model.
|
19
|
+
"""Ramifice - Field of Model.
|
16
20
|
|
17
21
|
Type of selective text field with dynamic addition of elements.
|
18
22
|
For simulate relationship Many-to-Many.
|
@@ -30,24 +34,28 @@ class ChoiceTextMultDynField(Field, ChoiceGroup, JsonMixin):
|
|
30
34
|
readonly: bool = False,
|
31
35
|
):
|
32
36
|
if constants.DEBUG:
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
37
|
+
try:
|
38
|
+
if not isinstance(label, str):
|
39
|
+
raise AssertionError("Parameter `default` - Not а `str` type!")
|
40
|
+
if not isinstance(disabled, bool):
|
41
|
+
raise AssertionError("Parameter `disabled` - Not а `bool` type!")
|
42
|
+
if not isinstance(hide, bool):
|
43
|
+
raise AssertionError("Parameter `hide` - Not а `bool` type!")
|
44
|
+
if not isinstance(ignored, bool):
|
45
|
+
raise AssertionError("Parameter `ignored` - Not а `bool` type!")
|
46
|
+
if not isinstance(ignored, bool):
|
47
|
+
raise AssertionError("Parameter `ignored` - Not а `bool` type!")
|
48
|
+
if not isinstance(hint, str):
|
49
|
+
raise AssertionError("Parameter `hint` - Not а `str` type!")
|
50
|
+
if warning is not None and not isinstance(warning, list):
|
51
|
+
raise AssertionError("Parameter `warning` - Not а `list` type!")
|
52
|
+
if not isinstance(required, bool):
|
53
|
+
raise AssertionError("Parameter `required` - Not а `bool` type!")
|
54
|
+
if not isinstance(readonly, bool):
|
55
|
+
raise AssertionError("Parameter `readonly` - Not а `bool` type!")
|
56
|
+
except AssertionError as err:
|
57
|
+
logger.error(str(err))
|
58
|
+
raise err
|
51
59
|
|
52
60
|
Field.__init__(
|
53
61
|
self,
|
@@ -72,7 +80,7 @@ class ChoiceTextMultDynField(Field, ChoiceGroup, JsonMixin):
|
|
72
80
|
self.choices: list[list[str]] | None = None
|
73
81
|
|
74
82
|
def has_value(self, is_migrate: bool = False) -> bool:
|
75
|
-
"""Does the field value match the possible options in choices."""
|
83
|
+
"""Ramifice - Does the field value match the possible options in choices."""
|
76
84
|
if is_migrate:
|
77
85
|
return True
|
78
86
|
value = self.value
|
@@ -1,18 +1,22 @@
|
|
1
|
-
"""Field of Model.
|
1
|
+
"""Ramifice - Field of Model.
|
2
2
|
|
3
3
|
Type of selective text field with static of elements.
|
4
4
|
"""
|
5
5
|
|
6
6
|
__all__ = ("ChoiceTextMultField",)
|
7
7
|
|
8
|
+
import logging
|
9
|
+
|
8
10
|
from ramifice.fields.general.choice_group import ChoiceGroup
|
9
11
|
from ramifice.fields.general.field import Field
|
10
12
|
from ramifice.utils import constants
|
11
13
|
from ramifice.utils.mixins.json_converter import JsonMixin
|
12
14
|
|
15
|
+
logger = logging.getLogger(__name__)
|
16
|
+
|
13
17
|
|
14
18
|
class ChoiceTextMultField(Field, ChoiceGroup, JsonMixin):
|
15
|
-
"""Field of Model.
|
19
|
+
"""Ramifice - Field of Model.
|
16
20
|
|
17
21
|
Type of selective text field with static of elements.
|
18
22
|
With multiple choice.
|
@@ -55,46 +59,50 @@ class ChoiceTextMultField(Field, ChoiceGroup, JsonMixin):
|
|
55
59
|
self.choices = choices
|
56
60
|
|
57
61
|
if constants.DEBUG:
|
58
|
-
|
59
|
-
if not
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
if not
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
62
|
+
try:
|
63
|
+
if choices is not None:
|
64
|
+
if not isinstance(choices, list):
|
65
|
+
raise AssertionError("Parameter `choices` - Not а `list` type!")
|
66
|
+
if len(choices) == 0:
|
67
|
+
raise AssertionError(
|
68
|
+
"The `choices` parameter should not contain an empty list!"
|
69
|
+
)
|
70
|
+
if default is not None:
|
71
|
+
if not isinstance(default, list):
|
72
|
+
raise AssertionError("Parameter `default` - Not а `list` type!")
|
73
|
+
if len(default) == 0:
|
74
|
+
raise AssertionError(
|
75
|
+
"The `default` parameter should not contain an empty list!"
|
76
|
+
)
|
77
|
+
if choices is not None and not self.has_value():
|
78
|
+
raise AssertionError(
|
79
|
+
"Parameter `default` does not coincide with "
|
80
|
+
+ "list of permissive values in `choicees`."
|
81
|
+
)
|
82
|
+
if not isinstance(label, str):
|
83
|
+
raise AssertionError("Parameter `default` - Not а `str` type!")
|
84
|
+
if not isinstance(disabled, bool):
|
85
|
+
raise AssertionError("Parameter `disabled` - Not а `bool` type!")
|
86
|
+
if not isinstance(hide, bool):
|
87
|
+
raise AssertionError("Parameter `hide` - Not а `bool` type!")
|
88
|
+
if not isinstance(ignored, bool):
|
89
|
+
raise AssertionError("Parameter `ignored` - Not а `bool` type!")
|
90
|
+
if not isinstance(ignored, bool):
|
91
|
+
raise AssertionError("Parameter `ignored` - Not а `bool` type!")
|
92
|
+
if not isinstance(hint, str):
|
93
|
+
raise AssertionError("Parameter `hint` - Not а `str` type!")
|
94
|
+
if warning is not None and not isinstance(warning, list):
|
95
|
+
raise AssertionError("Parameter `warning` - Not а `list` type!")
|
96
|
+
if not isinstance(required, bool):
|
97
|
+
raise AssertionError("Parameter `required` - Not а `bool` type!")
|
98
|
+
if not isinstance(readonly, bool):
|
99
|
+
raise AssertionError("Parameter `readonly` - Not а `bool` type!")
|
100
|
+
except AssertionError as err:
|
101
|
+
logger.error(str(err))
|
102
|
+
raise err
|
95
103
|
|
96
104
|
def has_value(self, is_migrate: bool = False) -> bool:
|
97
|
-
"""Does the field value match the possible options in choices."""
|
105
|
+
"""Ramifice - Does the field value match the possible options in choices."""
|
98
106
|
value = self.value
|
99
107
|
if value is None:
|
100
108
|
value = self.default
|
ramifice/fields/color_field.py
CHANGED
@@ -1,15 +1,19 @@
|
|
1
|
-
"""Field of Model for enter color code."""
|
1
|
+
"""Ramifice - Field of Model for enter color code."""
|
2
2
|
|
3
3
|
__all__ = ("ColorField",)
|
4
4
|
|
5
|
+
import logging
|
6
|
+
|
5
7
|
from ramifice.fields.general.field import Field
|
6
8
|
from ramifice.fields.general.text_group import TextGroup
|
7
9
|
from ramifice.utils import constants
|
8
10
|
from ramifice.utils.mixins.json_converter import JsonMixin
|
9
11
|
|
12
|
+
logger = logging.getLogger(__name__)
|
13
|
+
|
10
14
|
|
11
15
|
class ColorField(Field, TextGroup, JsonMixin):
|
12
|
-
"""Field of Model for enter color code.
|
16
|
+
"""Ramifice - Field of Model for enter color code.
|
13
17
|
|
14
18
|
Default value is #000000 (black).
|
15
19
|
|
@@ -34,37 +38,41 @@ class ColorField(Field, TextGroup, JsonMixin):
|
|
34
38
|
unique: bool = False,
|
35
39
|
):
|
36
40
|
if constants.DEBUG:
|
37
|
-
|
38
|
-
if not
|
41
|
+
try:
|
42
|
+
if default is not None:
|
43
|
+
if not isinstance(default, str):
|
44
|
+
raise AssertionError("Parameter `default` - Not а `str` type!")
|
45
|
+
if len(default) == 0:
|
46
|
+
raise AssertionError(
|
47
|
+
"The `default` parameter should not contain an empty string!"
|
48
|
+
)
|
49
|
+
if constants.REGEX["color_code"].match(default) is None:
|
50
|
+
raise AssertionError("Parameter `default` - Not а color code!")
|
51
|
+
if not isinstance(label, str):
|
39
52
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
40
|
-
if
|
41
|
-
raise AssertionError(
|
42
|
-
|
43
|
-
)
|
44
|
-
if
|
45
|
-
raise AssertionError("Parameter `
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
raise AssertionError("Parameter `required` - Not а `bool` type!")
|
64
|
-
if not isinstance(readonly, bool):
|
65
|
-
raise AssertionError("Parameter `readonly` - Not а `bool` type!")
|
66
|
-
if not isinstance(unique, bool):
|
67
|
-
raise AssertionError("Parameter `unique` - Not а `bool` type!")
|
53
|
+
if not isinstance(disabled, bool):
|
54
|
+
raise AssertionError("Parameter `disabled` - Not а `bool` type!")
|
55
|
+
if not isinstance(hide, bool):
|
56
|
+
raise AssertionError("Parameter `hide` - Not а `bool` type!")
|
57
|
+
if not isinstance(ignored, bool):
|
58
|
+
raise AssertionError("Parameter `ignored` - Not а `bool` type!")
|
59
|
+
if not isinstance(ignored, bool):
|
60
|
+
raise AssertionError("Parameter `ignored` - Not а `bool` type!")
|
61
|
+
if not isinstance(hint, str):
|
62
|
+
raise AssertionError("Parameter `hint` - Not а `str` type!")
|
63
|
+
if warning is not None and not isinstance(warning, list):
|
64
|
+
raise AssertionError("Parameter `warning` - Not а `list` type!")
|
65
|
+
if not isinstance(placeholder, str):
|
66
|
+
raise AssertionError("Parameter `placeholder` - Not а `str` type!")
|
67
|
+
if not isinstance(required, bool):
|
68
|
+
raise AssertionError("Parameter `required` - Not а `bool` type!")
|
69
|
+
if not isinstance(readonly, bool):
|
70
|
+
raise AssertionError("Parameter `readonly` - Not а `bool` type!")
|
71
|
+
if not isinstance(unique, bool):
|
72
|
+
raise AssertionError("Parameter `unique` - Not а `bool` type!")
|
73
|
+
except AssertionError as err:
|
74
|
+
logger.error(str(err))
|
75
|
+
raise err
|
68
76
|
|
69
77
|
Field.__init__(
|
70
78
|
self,
|