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
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Field of Model.
|
2
2
|
|
3
3
|
Type of selective integer field with dynamic addition of elements.
|
4
4
|
"""
|
@@ -10,30 +10,40 @@ import logging
|
|
10
10
|
from ramifice.fields.general.choice_group import ChoiceGroup
|
11
11
|
from ramifice.fields.general.field import Field
|
12
12
|
from ramifice.utils import constants
|
13
|
-
from ramifice.utils.mixins
|
13
|
+
from ramifice.utils.mixins import JsonMixin
|
14
14
|
|
15
15
|
logger = logging.getLogger(__name__)
|
16
16
|
|
17
17
|
|
18
18
|
class ChoiceIntDynField(Field, ChoiceGroup, JsonMixin):
|
19
|
-
"""
|
19
|
+
"""Field of Model.
|
20
20
|
|
21
21
|
Type of selective integer field with dynamic addition of elements.
|
22
22
|
For simulate relationship Many-to-One.
|
23
23
|
Element are (add|delete) via `ModelName.unit_manager(unit)` method.
|
24
|
+
|
25
|
+
Args:
|
26
|
+
label: Text label for a web form field.
|
27
|
+
hide: Hide field from user.
|
28
|
+
disabled: Blocks access and modification of the element.
|
29
|
+
ignored: If true, the value of this field is not saved in the database.
|
30
|
+
hint: An alternative for the `placeholder` parameter.
|
31
|
+
warning: Warning information.
|
32
|
+
required: Required field.
|
33
|
+
readonly: Specifies that the field cannot be modified by the user.
|
24
34
|
"""
|
25
35
|
|
26
36
|
def __init__( # noqa: D107
|
27
37
|
self,
|
28
38
|
label: str = "",
|
29
|
-
disabled: bool = False,
|
30
39
|
hide: bool = False,
|
40
|
+
disabled: bool = False,
|
31
41
|
ignored: bool = False,
|
32
42
|
hint: str = "",
|
33
43
|
warning: list[str] | None = None,
|
34
44
|
required: bool = False,
|
35
45
|
readonly: bool = False,
|
36
|
-
):
|
46
|
+
) -> None:
|
37
47
|
if constants.DEBUG:
|
38
48
|
try:
|
39
49
|
if not isinstance(label, str):
|
@@ -80,7 +90,7 @@ class ChoiceIntDynField(Field, ChoiceGroup, JsonMixin):
|
|
80
90
|
self.choices: list[list[int | str]] | None = None
|
81
91
|
|
82
92
|
def has_value(self, is_migrate: bool = False) -> bool:
|
83
|
-
"""
|
93
|
+
"""Does the field value match the possible options in choices."""
|
84
94
|
if is_migrate:
|
85
95
|
return True
|
86
96
|
value = self.value
|
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Field of Model.
|
2
2
|
|
3
3
|
Type of selective integer field with static of elements.
|
4
4
|
"""
|
@@ -10,31 +10,43 @@ import logging
|
|
10
10
|
from ramifice.fields.general.choice_group import ChoiceGroup
|
11
11
|
from ramifice.fields.general.field import Field
|
12
12
|
from ramifice.utils import constants
|
13
|
-
from ramifice.utils.mixins
|
13
|
+
from ramifice.utils.mixins import JsonMixin
|
14
14
|
|
15
15
|
logger = logging.getLogger(__name__)
|
16
16
|
|
17
17
|
|
18
18
|
class ChoiceIntField(Field, ChoiceGroup, JsonMixin):
|
19
|
-
"""
|
19
|
+
"""Field of Model.
|
20
20
|
|
21
21
|
Type of selective integer field with static of elements.
|
22
22
|
With a single choice.
|
23
|
+
|
24
|
+
Args:
|
25
|
+
label: Text label for a web form field.
|
26
|
+
default: Default value.
|
27
|
+
hide: Hide field from user.
|
28
|
+
disabled: Blocks access and modification of the element.
|
29
|
+
required: Required field.
|
30
|
+
readonly: Specifies that the field cannot be modified by the user.
|
31
|
+
ignored: If true, the value of this field is not saved in the database.
|
32
|
+
hint: An alternative for the `placeholder` parameter.
|
33
|
+
warning: Warning information.
|
34
|
+
choices: For a predefined set of options - [[value, Title], ...].
|
23
35
|
"""
|
24
36
|
|
25
37
|
def __init__( # noqa: D107
|
26
38
|
self,
|
27
39
|
label: str = "",
|
28
|
-
|
40
|
+
default: int | None = None,
|
29
41
|
hide: bool = False,
|
42
|
+
disabled: bool = False,
|
30
43
|
ignored: bool = False,
|
31
44
|
hint: str = "",
|
32
45
|
warning: list[str] | None = None,
|
33
|
-
default: int | None = None,
|
34
46
|
required: bool = False,
|
35
47
|
readonly: bool = False,
|
36
|
-
choices: list[list[int | str]] | None = None,
|
37
|
-
):
|
48
|
+
choices: list[list[int | str]] | None = None, # [[value, Title], ...]
|
49
|
+
) -> None:
|
38
50
|
Field.__init__(
|
39
51
|
self,
|
40
52
|
label=label,
|
@@ -96,7 +108,7 @@ class ChoiceIntField(Field, ChoiceGroup, JsonMixin):
|
|
96
108
|
raise err
|
97
109
|
|
98
110
|
def has_value(self, is_migrate: bool = False) -> bool:
|
99
|
-
"""
|
111
|
+
"""Does the field value match the possible options in choices."""
|
100
112
|
value = self.value
|
101
113
|
if value is None:
|
102
114
|
value = self.default
|
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Field of Model.
|
2
2
|
|
3
3
|
Type of selective integer field with dynamic addition of elements.
|
4
4
|
"""
|
@@ -10,29 +10,39 @@ import logging
|
|
10
10
|
from ramifice.fields.general.choice_group import ChoiceGroup
|
11
11
|
from ramifice.fields.general.field import Field
|
12
12
|
from ramifice.utils import constants
|
13
|
-
from ramifice.utils.mixins
|
13
|
+
from ramifice.utils.mixins import JsonMixin
|
14
14
|
|
15
15
|
logger = logging.getLogger(__name__)
|
16
16
|
|
17
17
|
|
18
18
|
class ChoiceIntMultDynField(Field, ChoiceGroup, JsonMixin):
|
19
|
-
"""
|
19
|
+
"""Field of Model.
|
20
20
|
|
21
21
|
Type of selective integer field with dynamic addition of elements.
|
22
22
|
For simulate relationship Many-to-Many.
|
23
|
+
|
24
|
+
Args:
|
25
|
+
label: Text label for a web form field.
|
26
|
+
hide: Hide field from user.
|
27
|
+
disabled: Blocks access and modification of the element.
|
28
|
+
ignored: If true, the value of this field is not saved in the database.
|
29
|
+
hint: An alternative for the `placeholder` parameter.
|
30
|
+
warning: Warning information.
|
31
|
+
required: Required field.
|
32
|
+
readonly: Specifies that the field cannot be modified by the user.
|
23
33
|
"""
|
24
34
|
|
25
35
|
def __init__( # noqa: D107
|
26
36
|
self,
|
27
37
|
label: str = "",
|
28
|
-
disabled: bool = False,
|
29
38
|
hide: bool = False,
|
39
|
+
disabled: bool = False,
|
30
40
|
ignored: bool = False,
|
31
41
|
hint: str = "",
|
32
42
|
warning: list[str] | None = None,
|
33
43
|
required: bool = False,
|
34
44
|
readonly: bool = False,
|
35
|
-
):
|
45
|
+
) -> None:
|
36
46
|
if constants.DEBUG:
|
37
47
|
try:
|
38
48
|
if not isinstance(label, str):
|
@@ -80,7 +90,7 @@ class ChoiceIntMultDynField(Field, ChoiceGroup, JsonMixin):
|
|
80
90
|
self.choices: list[list[int | str]] | None = None
|
81
91
|
|
82
92
|
def has_value(self, is_migrate: bool = False) -> bool:
|
83
|
-
"""
|
93
|
+
"""Does the field value match the possible options in choices."""
|
84
94
|
if is_migrate:
|
85
95
|
return True
|
86
96
|
value = self.value
|
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Field of Model.
|
2
2
|
|
3
3
|
Type of selective integer field with static of elements.
|
4
4
|
"""
|
@@ -10,31 +10,43 @@ import logging
|
|
10
10
|
from ramifice.fields.general.choice_group import ChoiceGroup
|
11
11
|
from ramifice.fields.general.field import Field
|
12
12
|
from ramifice.utils import constants
|
13
|
-
from ramifice.utils.mixins
|
13
|
+
from ramifice.utils.mixins import JsonMixin
|
14
14
|
|
15
15
|
logger = logging.getLogger(__name__)
|
16
16
|
|
17
17
|
|
18
18
|
class ChoiceIntMultField(Field, ChoiceGroup, JsonMixin):
|
19
|
-
"""
|
19
|
+
"""Field of Model.
|
20
20
|
|
21
21
|
Type of selective integer field with static of elements.
|
22
22
|
With multiple choice.
|
23
|
+
|
24
|
+
Args:
|
25
|
+
label: Text label for a web form field.
|
26
|
+
default: Default value.
|
27
|
+
hide: Hide field from user.
|
28
|
+
disabled: Blocks access and modification of the element.
|
29
|
+
ignored: If true, the value of this field is not saved in the database.
|
30
|
+
hint: An alternative for the `placeholder` parameter.
|
31
|
+
warning: Warning information.
|
32
|
+
required: Required field.
|
33
|
+
readonly: Specifies that the field cannot be modified by the user.
|
34
|
+
choices: For a predefined set of options - [[value, Title], ...].
|
23
35
|
"""
|
24
36
|
|
25
37
|
def __init__( # noqa: D107
|
26
38
|
self,
|
27
39
|
label: str = "",
|
28
|
-
|
40
|
+
default: list[int] | None = None,
|
29
41
|
hide: bool = False,
|
42
|
+
disabled: bool = False,
|
30
43
|
ignored: bool = False,
|
31
44
|
hint: str = "",
|
32
45
|
warning: list[str] | None = None,
|
33
|
-
default: list[int] | None = None,
|
34
46
|
required: bool = False,
|
35
47
|
readonly: bool = False,
|
36
|
-
choices: list[list[int | str]] | None = None,
|
37
|
-
):
|
48
|
+
choices: list[list[int | str]] | None = None, # [[value, Title], ...]
|
49
|
+
) -> None:
|
38
50
|
Field.__init__(
|
39
51
|
self,
|
40
52
|
label=label,
|
@@ -102,7 +114,7 @@ class ChoiceIntMultField(Field, ChoiceGroup, JsonMixin):
|
|
102
114
|
raise err
|
103
115
|
|
104
116
|
def has_value(self, is_migrate: bool = False) -> bool:
|
105
|
-
"""
|
117
|
+
"""Does the field value match the possible options in choices."""
|
106
118
|
value = self.value
|
107
119
|
if value is None:
|
108
120
|
value = self.default
|
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Field of Model.
|
2
2
|
|
3
3
|
Type of selective text field with dynamic addition of elements.
|
4
4
|
"""
|
@@ -10,30 +10,40 @@ import logging
|
|
10
10
|
from ramifice.fields.general.choice_group import ChoiceGroup
|
11
11
|
from ramifice.fields.general.field import Field
|
12
12
|
from ramifice.utils import constants
|
13
|
-
from ramifice.utils.mixins
|
13
|
+
from ramifice.utils.mixins import JsonMixin
|
14
14
|
|
15
15
|
logger = logging.getLogger(__name__)
|
16
16
|
|
17
17
|
|
18
18
|
class ChoiceTextDynField(Field, ChoiceGroup, JsonMixin):
|
19
|
-
"""
|
19
|
+
"""Field of Model.
|
20
20
|
|
21
21
|
Type of selective text field with dynamic addition of elements.
|
22
22
|
For simulate relationship Many-to-One.
|
23
23
|
Element are (add|delete) via `ModelName.unit_manager(unit)` method.
|
24
|
+
|
25
|
+
Args:
|
26
|
+
label: Text label for a web form field.
|
27
|
+
hide: Hide field from user.
|
28
|
+
disabled: Blocks access and modification of the element.
|
29
|
+
ignored: If true, the value of this field is not saved in the database.
|
30
|
+
hint: An alternative for the `placeholder` parameter.
|
31
|
+
warning: Warning information.
|
32
|
+
required: Required field.
|
33
|
+
readonly: Specifies that the field cannot be modified by the user.
|
24
34
|
"""
|
25
35
|
|
26
36
|
def __init__( # noqa: D107
|
27
37
|
self,
|
28
38
|
label: str = "",
|
29
|
-
disabled: bool = False,
|
30
39
|
hide: bool = False,
|
40
|
+
disabled: bool = False,
|
31
41
|
ignored: bool = False,
|
32
42
|
hint: str = "",
|
33
43
|
warning: list[str] | None = None,
|
34
44
|
required: bool = False,
|
35
45
|
readonly: bool = False,
|
36
|
-
):
|
46
|
+
) -> None:
|
37
47
|
if constants.DEBUG:
|
38
48
|
try:
|
39
49
|
if not isinstance(label, str):
|
@@ -80,7 +90,7 @@ class ChoiceTextDynField(Field, ChoiceGroup, JsonMixin):
|
|
80
90
|
self.choices: list[list[str]] | None = None
|
81
91
|
|
82
92
|
def has_value(self, is_migrate: bool = False) -> bool:
|
83
|
-
"""
|
93
|
+
"""Does the field value match the possible options in choices."""
|
84
94
|
if is_migrate:
|
85
95
|
return True
|
86
96
|
value = self.value
|
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Field of Model.
|
2
2
|
|
3
3
|
Type of selective text field with static of elements.
|
4
4
|
"""
|
@@ -10,31 +10,43 @@ import logging
|
|
10
10
|
from ramifice.fields.general.choice_group import ChoiceGroup
|
11
11
|
from ramifice.fields.general.field import Field
|
12
12
|
from ramifice.utils import constants
|
13
|
-
from ramifice.utils.mixins
|
13
|
+
from ramifice.utils.mixins import JsonMixin
|
14
14
|
|
15
15
|
logger = logging.getLogger(__name__)
|
16
16
|
|
17
17
|
|
18
18
|
class ChoiceTextField(Field, ChoiceGroup, JsonMixin):
|
19
|
-
"""
|
19
|
+
"""Field of Model.
|
20
20
|
|
21
21
|
Type of selective text field with static of elements.
|
22
22
|
With a single choice.
|
23
|
+
|
24
|
+
Args:
|
25
|
+
label: Text label for a web form field.
|
26
|
+
default: Default value.
|
27
|
+
hide: Hide field from user.
|
28
|
+
disabled: Blocks access and modification of the element.
|
29
|
+
required: Required field.
|
30
|
+
readonly: Specifies that the field cannot be modified by the user.
|
31
|
+
ignored: If true, the value of this field is not saved in the database.
|
32
|
+
hint: An alternative for the `placeholder` parameter.
|
33
|
+
warning: Warning information.
|
34
|
+
choices: For a predefined set of options - [[value, Title], ...].
|
23
35
|
"""
|
24
36
|
|
25
37
|
def __init__( # noqa: D107
|
26
38
|
self,
|
27
39
|
label: str = "",
|
28
|
-
|
40
|
+
default: str | None = None,
|
29
41
|
hide: bool = False,
|
42
|
+
disabled: bool = False,
|
30
43
|
ignored: bool = False,
|
31
44
|
hint: str = "",
|
32
45
|
warning: list[str] | None = None,
|
33
|
-
default: str | None = None,
|
34
46
|
required: bool = False,
|
35
47
|
readonly: bool = False,
|
36
|
-
choices: list[list[str]] | None = None,
|
37
|
-
):
|
48
|
+
choices: list[list[str]] | None = None, # [[value, Title], ...]
|
49
|
+
) -> None:
|
38
50
|
Field.__init__(
|
39
51
|
self,
|
40
52
|
label=label,
|
@@ -101,7 +113,7 @@ class ChoiceTextField(Field, ChoiceGroup, JsonMixin):
|
|
101
113
|
raise err
|
102
114
|
|
103
115
|
def has_value(self, is_migrate: bool = False) -> bool:
|
104
|
-
"""
|
116
|
+
"""Does the field value match the possible options in choices."""
|
105
117
|
value = self.value
|
106
118
|
if value is None:
|
107
119
|
value = self.default
|
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Field of Model.
|
2
2
|
|
3
3
|
Type of selective text field with dynamic addition of elements.
|
4
4
|
"""
|
@@ -10,29 +10,39 @@ import logging
|
|
10
10
|
from ramifice.fields.general.choice_group import ChoiceGroup
|
11
11
|
from ramifice.fields.general.field import Field
|
12
12
|
from ramifice.utils import constants
|
13
|
-
from ramifice.utils.mixins
|
13
|
+
from ramifice.utils.mixins import JsonMixin
|
14
14
|
|
15
15
|
logger = logging.getLogger(__name__)
|
16
16
|
|
17
17
|
|
18
18
|
class ChoiceTextMultDynField(Field, ChoiceGroup, JsonMixin):
|
19
|
-
"""
|
19
|
+
"""Field of Model.
|
20
20
|
|
21
21
|
Type of selective text field with dynamic addition of elements.
|
22
22
|
For simulate relationship Many-to-Many.
|
23
|
+
|
24
|
+
Args:
|
25
|
+
label: Text label for a web form field.
|
26
|
+
hide: Hide field from user.
|
27
|
+
disabled: Blocks access and modification of the element.
|
28
|
+
ignored: If true, the value of this field is not saved in the database.
|
29
|
+
hint: An alternative for the `placeholder` parameter.
|
30
|
+
warning: Warning information.
|
31
|
+
required: Required field.
|
32
|
+
readonly: Specifies that the field cannot be modified by the user.
|
23
33
|
"""
|
24
34
|
|
25
35
|
def __init__( # noqa: D107
|
26
36
|
self,
|
27
37
|
label: str = "",
|
28
|
-
disabled: bool = False,
|
29
38
|
hide: bool = False,
|
39
|
+
disabled: bool = False,
|
30
40
|
ignored: bool = False,
|
31
41
|
hint: str = "",
|
32
42
|
warning: list[str] | None = None,
|
33
43
|
required: bool = False,
|
34
44
|
readonly: bool = False,
|
35
|
-
):
|
45
|
+
) -> None:
|
36
46
|
if constants.DEBUG:
|
37
47
|
try:
|
38
48
|
if not isinstance(label, str):
|
@@ -80,7 +90,7 @@ class ChoiceTextMultDynField(Field, ChoiceGroup, JsonMixin):
|
|
80
90
|
self.choices: list[list[str]] | None = None
|
81
91
|
|
82
92
|
def has_value(self, is_migrate: bool = False) -> bool:
|
83
|
-
"""
|
93
|
+
"""Does the field value match the possible options in choices."""
|
84
94
|
if is_migrate:
|
85
95
|
return True
|
86
96
|
value = self.value
|
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Field of Model.
|
2
2
|
|
3
3
|
Type of selective text field with static of elements.
|
4
4
|
"""
|
@@ -10,31 +10,43 @@ import logging
|
|
10
10
|
from ramifice.fields.general.choice_group import ChoiceGroup
|
11
11
|
from ramifice.fields.general.field import Field
|
12
12
|
from ramifice.utils import constants
|
13
|
-
from ramifice.utils.mixins
|
13
|
+
from ramifice.utils.mixins import JsonMixin
|
14
14
|
|
15
15
|
logger = logging.getLogger(__name__)
|
16
16
|
|
17
17
|
|
18
18
|
class ChoiceTextMultField(Field, ChoiceGroup, JsonMixin):
|
19
|
-
"""
|
19
|
+
"""Field of Model.
|
20
20
|
|
21
21
|
Type of selective text field with static of elements.
|
22
22
|
With multiple choice.
|
23
|
+
|
24
|
+
Args:
|
25
|
+
label: Text label for a web form field.
|
26
|
+
default: Default value.
|
27
|
+
hide: Hide field from user.
|
28
|
+
disabled: Blocks access and modification of the element.
|
29
|
+
ignored: If true, the value of this field is not saved in the database.
|
30
|
+
hint: An alternative for the `placeholder` parameter.
|
31
|
+
warning: Warning information.
|
32
|
+
required: Required field.
|
33
|
+
readonly: Specifies that the field cannot be modified by the user.
|
34
|
+
choices: For a predefined set of options - [[value, Title], ...].
|
23
35
|
"""
|
24
36
|
|
25
37
|
def __init__( # noqa: D107
|
26
38
|
self,
|
27
39
|
label: str = "",
|
28
|
-
|
40
|
+
default: list[str] | None = None,
|
29
41
|
hide: bool = False,
|
42
|
+
disabled: bool = False,
|
30
43
|
ignored: bool = False,
|
31
44
|
hint: str = "",
|
32
45
|
warning: list[str] | None = None,
|
33
|
-
default: list[str] | None = None,
|
34
46
|
required: bool = False,
|
35
47
|
readonly: bool = False,
|
36
|
-
choices: list[list[str]] | None = None,
|
37
|
-
):
|
48
|
+
choices: list[list[str]] | None = None, # [[value, Title], ...]
|
49
|
+
) -> None:
|
38
50
|
Field.__init__(
|
39
51
|
self,
|
40
52
|
label=label,
|
@@ -102,7 +114,7 @@ class ChoiceTextMultField(Field, ChoiceGroup, JsonMixin):
|
|
102
114
|
raise err
|
103
115
|
|
104
116
|
def has_value(self, is_migrate: bool = False) -> bool:
|
105
|
-
"""
|
117
|
+
"""Does the field value match the possible options in choices."""
|
106
118
|
value = self.value
|
107
119
|
if value is None:
|
108
120
|
value = self.default
|
ramifice/fields/color_field.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Field of Model for enter color code."""
|
2
2
|
|
3
3
|
__all__ = ("ColorField",)
|
4
4
|
|
@@ -7,36 +7,49 @@ import logging
|
|
7
7
|
from ramifice.fields.general.field import Field
|
8
8
|
from ramifice.fields.general.text_group import TextGroup
|
9
9
|
from ramifice.utils import constants
|
10
|
-
from ramifice.utils.mixins
|
10
|
+
from ramifice.utils.mixins import JsonMixin
|
11
11
|
|
12
12
|
logger = logging.getLogger(__name__)
|
13
13
|
|
14
14
|
|
15
15
|
class ColorField(Field, TextGroup, JsonMixin):
|
16
|
-
"""
|
16
|
+
"""Field of Model for enter color code.
|
17
17
|
|
18
18
|
Default value is #000000 (black).
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
Samples:
|
21
|
+
#ffffff | #fff | #f2f2f2 | #f2f2f200 | rgb(255,0,24) |
|
22
|
+
rgba(255,0,24,0.5) | rgba(#fff,0.5) | hsl(120,100%,50%) |
|
23
|
+
hsla(170,23%,25%,0.2) | 0x00ffff
|
24
|
+
|
25
|
+
Agrs:
|
26
|
+
label: Text label for a web form field.
|
27
|
+
placeholder: Displays prompt text.
|
28
|
+
default: Value by default.
|
29
|
+
hide: Hide field from user.
|
30
|
+
disabled: Blocks access and modification of the element.
|
31
|
+
ignored: If true, the value of this field is not saved in the database.
|
32
|
+
hint: An alternative for the `placeholder` parameter.
|
33
|
+
warning: Warning information.
|
34
|
+
required: Required field.
|
35
|
+
readonly: Specifies that the field cannot be modified by the user.
|
36
|
+
unique: The unique value of a field in a collection.
|
24
37
|
"""
|
25
38
|
|
26
39
|
def __init__( # noqa: D107
|
27
40
|
self,
|
28
41
|
label: str = "",
|
29
|
-
|
42
|
+
placeholder: str = "",
|
43
|
+
default: str | None = "#000000",
|
30
44
|
hide: bool = False,
|
45
|
+
disabled: bool = False,
|
31
46
|
ignored: bool = False,
|
32
47
|
hint: str = "",
|
33
48
|
warning: list[str] | None = None,
|
34
|
-
default: str | None = "#000000",
|
35
|
-
placeholder: str = "",
|
36
49
|
required: bool = False,
|
37
50
|
readonly: bool = False,
|
38
51
|
unique: bool = False,
|
39
|
-
):
|
52
|
+
) -> None:
|
40
53
|
if constants.DEBUG:
|
41
54
|
try:
|
42
55
|
if default is not None:
|
ramifice/fields/date_field.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Field of Model for enter date."""
|
2
2
|
|
3
3
|
__all__ = ("DateField",)
|
4
4
|
|
@@ -18,23 +18,38 @@ logger = logging.getLogger(__name__)
|
|
18
18
|
|
19
19
|
|
20
20
|
class DateField(Field, DateGroup):
|
21
|
-
"""
|
21
|
+
"""Field of Model for enter date.
|
22
|
+
|
23
|
+
Agrs:
|
24
|
+
label: Text label for a web form field.
|
25
|
+
placeholder: Displays prompt text.
|
26
|
+
default: Value by default.
|
27
|
+
hide: Hide field from user.
|
28
|
+
disabled: Blocks access and modification of the element.
|
29
|
+
ignored: If true, the value of this field is not saved in the database.
|
30
|
+
hint: An alternative for the `placeholder` parameter.
|
31
|
+
warning: Warning information.
|
32
|
+
required: Required field.
|
33
|
+
readonly: Specifies that the field cannot be modified by the user.
|
34
|
+
max_date: Maximum allowed date.
|
35
|
+
min_date: Minimum allowed date.
|
36
|
+
"""
|
22
37
|
|
23
38
|
def __init__( # noqa: D107
|
24
39
|
self,
|
25
40
|
label: str = "",
|
26
|
-
|
41
|
+
placeholder: str = "",
|
42
|
+
default: datetime | None = None,
|
27
43
|
hide: bool = False,
|
44
|
+
disabled: bool = False,
|
28
45
|
ignored: bool = False,
|
29
46
|
hint: str = "",
|
30
47
|
warning: list[str] | None = None,
|
31
|
-
default: datetime | None = None,
|
32
|
-
placeholder: str = "",
|
33
48
|
required: bool = False,
|
34
49
|
readonly: bool = False,
|
35
50
|
max_date: datetime | None = None,
|
36
51
|
min_date: datetime | None = None,
|
37
|
-
):
|
52
|
+
) -> None:
|
38
53
|
if constants.DEBUG:
|
39
54
|
try:
|
40
55
|
if max_date is not None:
|
@@ -103,7 +118,7 @@ class DateField(Field, DateGroup):
|
|
103
118
|
self.default = default
|
104
119
|
|
105
120
|
def to_dict(self) -> dict[str, Any]:
|
106
|
-
"""
|
121
|
+
"""Convert object instance to a dictionary."""
|
107
122
|
json_dict: dict[str, Any] = {}
|
108
123
|
current_locale = translations.CURRENT_LOCALE
|
109
124
|
for name, value in self.__dict__.items():
|
@@ -119,12 +134,12 @@ class DateField(Field, DateGroup):
|
|
119
134
|
return json_dict
|
120
135
|
|
121
136
|
def to_json(self) -> str:
|
122
|
-
"""
|
137
|
+
"""Convert object instance to a JSON string."""
|
123
138
|
return orjson.dumps(self.to_dict()).decode("utf-8")
|
124
139
|
|
125
140
|
@classmethod
|
126
141
|
def from_dict(cls, json_dict: dict[str, Any]) -> Any:
|
127
|
-
"""
|
142
|
+
"""Convert JSON string to a object instance."""
|
128
143
|
obj = cls()
|
129
144
|
for name, value in json_dict.items():
|
130
145
|
if name == "value" and value is not None:
|
@@ -135,6 +150,6 @@ class DateField(Field, DateGroup):
|
|
135
150
|
|
136
151
|
@classmethod
|
137
152
|
def from_json(cls, json_str: str) -> Any:
|
138
|
-
"""
|
153
|
+
"""Convert JSON string to a object instance."""
|
139
154
|
json_dict = orjson.loads(json_str)
|
140
155
|
return cls.from_dict(json_dict)
|