ramifice 0.8.25__py3-none-any.whl → 0.8.27__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/commons/tools.py +1 -5
- ramifice/fields/bool_field.py +13 -3
- ramifice/fields/choice_float_dyn_field.py +11 -1
- ramifice/fields/choice_float_field.py +15 -3
- ramifice/fields/choice_float_mult_dyn_field.py +11 -1
- ramifice/fields/choice_float_mult_field.py +15 -3
- ramifice/fields/choice_int_dyn_field.py +11 -1
- ramifice/fields/choice_int_field.py +15 -3
- ramifice/fields/choice_int_mult_dyn_field.py +11 -1
- ramifice/fields/choice_int_mult_field.py +15 -3
- ramifice/fields/choice_text_dyn_field.py +11 -1
- ramifice/fields/choice_text_field.py +15 -3
- ramifice/fields/choice_text_mult_dyn_field.py +11 -1
- ramifice/fields/choice_text_mult_field.py +15 -3
- ramifice/fields/color_field.py +20 -7
- ramifice/fields/date_field.py +19 -4
- ramifice/fields/date_time_field.py +19 -4
- ramifice/fields/email_field.py +19 -5
- ramifice/fields/file_field.py +24 -11
- ramifice/fields/float_field.py +22 -4
- ramifice/fields/general/choice_group.py +1 -3
- ramifice/fields/general/date_group.py +1 -2
- ramifice/fields/general/field.py +2 -4
- ramifice/fields/general/file_group.py +1 -3
- ramifice/fields/general/number_group.py +1 -3
- ramifice/fields/general/text_group.py +1 -3
- ramifice/fields/id_field.py +13 -8
- ramifice/fields/image_field.py +25 -15
- ramifice/fields/integer_field.py +22 -4
- ramifice/fields/ip_field.py +19 -5
- ramifice/fields/password_field.py +14 -5
- ramifice/fields/phone_field.py +19 -5
- ramifice/fields/slug_field.py +14 -3
- ramifice/fields/text_field.py +20 -3
- ramifice/fields/url_field.py +15 -15
- ramifice/models/__init__.py +7 -1
- ramifice/models/decorator.py +2 -2
- ramifice/models/model.py +5 -7
- ramifice/paladins/__init__.py +16 -1
- ramifice/paladins/add_valid.py +3 -2
- ramifice/paladins/check.py +5 -5
- ramifice/paladins/groups/slug_group.py +1 -1
- ramifice/paladins/groups/text_group.py +2 -2
- ramifice/paladins/hooks.py +8 -2
- ramifice/paladins/indexing.py +3 -2
- ramifice/paladins/save.py +2 -2
- ramifice/paladins/validation.py +9 -9
- ramifice/utils/constants.py +1 -1
- ramifice/utils/fixtures.py +3 -3
- ramifice/utils/migration.py +3 -3
- ramifice/utils/tools.py +1 -1
- ramifice/utils/translations.py +1 -1
- ramifice/utils/unit.py +2 -2
- {ramifice-0.8.25.dist-info → ramifice-0.8.27.dist-info}/METADATA +2 -3
- ramifice-0.8.27.dist-info/RECORD +83 -0
- ramifice-0.8.25.dist-info/RECORD +0 -83
- {ramifice-0.8.25.dist-info → ramifice-0.8.27.dist-info}/WHEEL +0 -0
- {ramifice-0.8.25.dist-info → ramifice-0.8.27.dist-info}/licenses/LICENSE +0 -0
ramifice/commons/tools.py
CHANGED
@@ -21,11 +21,7 @@ def correct_mongo_filter(cls_model: Any, filter: Any) -> Any:
|
|
21
21
|
"""
|
22
22
|
lang: str = translations.CURRENT_LOCALE
|
23
23
|
filter_json: str = json_util.dumps(filter)
|
24
|
-
filter_json = (
|
25
|
-
cls_model.META["regex_mongo_filter"]
|
26
|
-
.sub(rf'\g<field>.{lang}":', filter_json)
|
27
|
-
.replace('":.', ".")
|
28
|
-
)
|
24
|
+
filter_json = cls_model.META["regex_mongo_filter"].sub(rf'\g<field>.{lang}":', filter_json).replace('":.', ".")
|
29
25
|
return json_util.loads(filter_json)
|
30
26
|
|
31
27
|
|
ramifice/fields/bool_field.py
CHANGED
@@ -12,17 +12,27 @@ logger = logging.getLogger(__name__)
|
|
12
12
|
|
13
13
|
|
14
14
|
class BooleanField(Field, JsonMixin):
|
15
|
-
"""Field of Model for enter boolean value.
|
15
|
+
"""Field of Model for enter boolean value.
|
16
|
+
|
17
|
+
Args:
|
18
|
+
label: Text label for a web form field.
|
19
|
+
default: Default value.
|
20
|
+
hide: Hide field from user.
|
21
|
+
disabled: Blocks access and modification of the element.
|
22
|
+
ignored: If true, the value of this field is not saved in the database.
|
23
|
+
hint: An alternative for the `placeholder` parameter.
|
24
|
+
warning: Warning information.
|
25
|
+
"""
|
16
26
|
|
17
27
|
def __init__( # noqa: D107
|
18
28
|
self,
|
19
29
|
label: str = "",
|
20
|
-
|
30
|
+
default: bool = False,
|
21
31
|
hide: bool = False,
|
32
|
+
disabled: bool = False,
|
22
33
|
ignored: bool = False,
|
23
34
|
hint: str = "",
|
24
35
|
warning: list[str] | None = None,
|
25
|
-
default: bool = False,
|
26
36
|
) -> None:
|
27
37
|
if constants.DEBUG:
|
28
38
|
try:
|
@@ -21,13 +21,23 @@ class ChoiceFloatDynField(Field, ChoiceGroup, JsonMixin):
|
|
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,
|
@@ -20,20 +20,32 @@ class ChoiceFloatField(Field, ChoiceGroup, JsonMixin):
|
|
20
20
|
|
21
21
|
Type of selective integer float 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: float | 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: float | None = None,
|
34
46
|
required: bool = False,
|
35
47
|
readonly: bool = False,
|
36
|
-
choices: list[list[float | str]] | None = None,
|
48
|
+
choices: list[list[float | str]] | None = None, # [[value, Title], ...]
|
37
49
|
) -> None:
|
38
50
|
Field.__init__(
|
39
51
|
self,
|
@@ -20,13 +20,23 @@ class ChoiceFloatMultDynField(Field, ChoiceGroup, JsonMixin):
|
|
20
20
|
|
21
21
|
Type of selective float 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,
|
@@ -20,20 +20,32 @@ class ChoiceFloatMultField(Field, ChoiceGroup, JsonMixin):
|
|
20
20
|
|
21
21
|
Type of selective float 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[float] | 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[float] | None = None,
|
34
46
|
required: bool = False,
|
35
47
|
readonly: bool = False,
|
36
|
-
choices: list[list[float | str]] | None = None,
|
48
|
+
choices: list[list[float | str]] | None = None, # [[value, Title], ...]
|
37
49
|
) -> None:
|
38
50
|
Field.__init__(
|
39
51
|
self,
|
@@ -21,13 +21,23 @@ class ChoiceIntDynField(Field, ChoiceGroup, JsonMixin):
|
|
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,
|
@@ -20,20 +20,32 @@ class ChoiceIntField(Field, ChoiceGroup, JsonMixin):
|
|
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,
|
48
|
+
choices: list[list[int | str]] | None = None, # [[value, Title], ...]
|
37
49
|
) -> None:
|
38
50
|
Field.__init__(
|
39
51
|
self,
|
@@ -20,13 +20,23 @@ class ChoiceIntMultDynField(Field, ChoiceGroup, JsonMixin):
|
|
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,
|
@@ -20,20 +20,32 @@ class ChoiceIntMultField(Field, ChoiceGroup, JsonMixin):
|
|
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,
|
48
|
+
choices: list[list[int | str]] | None = None, # [[value, Title], ...]
|
37
49
|
) -> None:
|
38
50
|
Field.__init__(
|
39
51
|
self,
|
@@ -21,13 +21,23 @@ class ChoiceTextDynField(Field, ChoiceGroup, JsonMixin):
|
|
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,
|
@@ -20,20 +20,32 @@ class ChoiceTextField(Field, ChoiceGroup, JsonMixin):
|
|
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,
|
48
|
+
choices: list[list[str]] | None = None, # [[value, Title], ...]
|
37
49
|
) -> None:
|
38
50
|
Field.__init__(
|
39
51
|
self,
|
@@ -20,13 +20,23 @@ class ChoiceTextMultDynField(Field, ChoiceGroup, JsonMixin):
|
|
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,
|
@@ -20,20 +20,32 @@ class ChoiceTextMultField(Field, ChoiceGroup, JsonMixin):
|
|
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,
|
48
|
+
choices: list[list[str]] | None = None, # [[value, Title], ...]
|
37
49
|
) -> None:
|
38
50
|
Field.__init__(
|
39
51
|
self,
|
ramifice/fields/color_field.py
CHANGED
@@ -17,22 +17,35 @@ class ColorField(Field, TextGroup, JsonMixin):
|
|
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,
|
ramifice/fields/date_field.py
CHANGED
@@ -18,18 +18,33 @@ logger = logging.getLogger(__name__)
|
|
18
18
|
|
19
19
|
|
20
20
|
class DateField(Field, DateGroup):
|
21
|
-
"""Field of Model for enter date.
|
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,
|
@@ -18,18 +18,33 @@ logger = logging.getLogger(__name__)
|
|
18
18
|
|
19
19
|
|
20
20
|
class DateTimeField(Field, DateGroup):
|
21
|
-
"""Field of Model for enter date and time.
|
21
|
+
"""Field of Model for enter date and time.
|
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 and time.
|
35
|
+
min_date: Minimum allowed date and time.
|
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,
|
ramifice/fields/email_field.py
CHANGED
@@ -15,18 +15,32 @@ logger = logging.getLogger(__name__)
|
|
15
15
|
|
16
16
|
|
17
17
|
class EmailField(Field, TextGroup, JsonMixin):
|
18
|
-
"""Field of Model for enter email address.
|
18
|
+
"""Field of Model for enter email address.
|
19
|
+
|
20
|
+
Agrs:
|
21
|
+
label: Text label for a web form field.
|
22
|
+
placeholder: Displays prompt text.
|
23
|
+
default: Value by default.
|
24
|
+
hide: Hide field from user.
|
25
|
+
disabled: Blocks access and modification of the element.
|
26
|
+
ignored: If true, the value of this field is not saved in the database.
|
27
|
+
hint: An alternative for the `placeholder` parameter.
|
28
|
+
warning: Warning information.
|
29
|
+
required: Required field.
|
30
|
+
readonly: Specifies that the field cannot be modified by the user.
|
31
|
+
unique: The unique value of a field in a collection.
|
32
|
+
"""
|
19
33
|
|
20
34
|
def __init__( # noqa: D107
|
21
35
|
self,
|
22
36
|
label: str = "",
|
23
|
-
|
37
|
+
placeholder: str = "",
|
38
|
+
default: str | None = None,
|
24
39
|
hide: bool = False,
|
40
|
+
disabled: bool = False,
|
25
41
|
ignored: bool = False,
|
26
42
|
hint: str = "",
|
27
43
|
warning: list[str] | None = None,
|
28
|
-
default: str | None = None,
|
29
|
-
placeholder: str = "",
|
30
44
|
required: bool = False,
|
31
45
|
readonly: bool = False,
|
32
46
|
unique: bool = False,
|
@@ -43,7 +57,7 @@ class EmailField(Field, TextGroup, JsonMixin):
|
|
43
57
|
try:
|
44
58
|
validate_email(default, check_deliverability=True)
|
45
59
|
except EmailNotValidError:
|
46
|
-
raise AssertionError("Parameter `default` - Invalid Email address!")
|
60
|
+
raise AssertionError("Parameter `default` - Invalid Email address!") # noqa: B904
|
47
61
|
if not isinstance(label, str):
|
48
62
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
49
63
|
if not isinstance(disabled, bool):
|
ramifice/fields/file_field.py
CHANGED
@@ -5,7 +5,7 @@ __all__ = ("FileField",)
|
|
5
5
|
import logging
|
6
6
|
import uuid
|
7
7
|
from base64 import b64decode
|
8
|
-
from datetime import
|
8
|
+
from datetime import datetime
|
9
9
|
from os import makedirs
|
10
10
|
from os.path import basename, exists, getsize
|
11
11
|
from shutil import copyfile
|
@@ -23,23 +23,38 @@ logger = logging.getLogger(__name__)
|
|
23
23
|
|
24
24
|
|
25
25
|
class FileField(Field, FileGroup, JsonMixin):
|
26
|
-
"""Field of Model for upload file.
|
26
|
+
"""Field of Model for upload file.
|
27
|
+
|
28
|
+
Agrs:
|
29
|
+
label: Text label for a web form field.
|
30
|
+
placeholder: Displays prompt text.
|
31
|
+
default: Value by default.
|
32
|
+
hide: Hide field from user.
|
33
|
+
disabled: Blocks access and modification of the element.
|
34
|
+
ignored: If true, the value of this field is not saved in the database.
|
35
|
+
hint: An alternative for the `placeholder` parameter.
|
36
|
+
warning: Warning information.
|
37
|
+
required: Required field.
|
38
|
+
max_size: The maximum allowed file size in bytes.
|
39
|
+
target_dir: Directory for files inside media directory.
|
40
|
+
accept: Describing which file types to allow. Example: ".pdf,.doc,.docx,application/msword".
|
41
|
+
"""
|
27
42
|
|
28
43
|
def __init__( # noqa: D107
|
29
44
|
self,
|
30
45
|
label: str = "",
|
31
|
-
|
46
|
+
placeholder: str = "",
|
47
|
+
default: str | None = None,
|
32
48
|
hide: bool = False,
|
49
|
+
disabled: bool = False,
|
33
50
|
ignored: bool = False,
|
34
51
|
hint: str = "",
|
35
52
|
warning: list[str] | None = None,
|
36
53
|
required: bool = False,
|
37
54
|
# The maximum size of the file in bytes.
|
38
55
|
max_size: int = 2097152, # 2 MB = 2097152 Bytes (in binary)
|
39
|
-
default: str | None = None,
|
40
|
-
placeholder: str = "",
|
41
56
|
target_dir: str = "files",
|
42
|
-
accept: str = "",
|
57
|
+
accept: str = "", # Example: ".pdf,.doc,.docx,application/msword"
|
43
58
|
) -> None:
|
44
59
|
if constants.DEBUG:
|
45
60
|
try:
|
@@ -47,9 +62,7 @@ class FileField(Field, FileGroup, JsonMixin):
|
|
47
62
|
if not isinstance(default, str):
|
48
63
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
49
64
|
if len(default) == 0:
|
50
|
-
raise AssertionError(
|
51
|
-
"The `default` parameter should not contain an empty string!"
|
52
|
-
)
|
65
|
+
raise AssertionError("The `default` parameter should not contain an empty string!")
|
53
66
|
if not isinstance(label, str):
|
54
67
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
55
68
|
if not isinstance(disabled, bool):
|
@@ -134,7 +147,7 @@ class FileField(Field, FileGroup, JsonMixin):
|
|
134
147
|
# Create new (uuid) file name.
|
135
148
|
f_uuid_name = f"{uuid.uuid4()}{extension}"
|
136
149
|
# Create the current date for the directory name.
|
137
|
-
date_str: str = str(
|
150
|
+
date_str: str = str(datetime.now().date()) # noqa: DTZ005
|
138
151
|
# Create path to target directory.
|
139
152
|
dir_target_path = f"{MEDIA_ROOT}/uploads/{self.target_dir}/{date_str}"
|
140
153
|
# Create target directory if it does not exist.
|
@@ -180,7 +193,7 @@ class FileField(Field, FileGroup, JsonMixin):
|
|
180
193
|
# Create new (uuid) file name.
|
181
194
|
f_uuid_name = f"{uuid.uuid4()}{extension}"
|
182
195
|
# Create the current date for the directory name.
|
183
|
-
date_str: str = str(
|
196
|
+
date_str: str = str(datetime.now().date()) # noqa: DTZ005
|
184
197
|
# Create path to target directory.
|
185
198
|
dir_target_path = f"{MEDIA_ROOT}/uploads/{self.target_dir}/{date_str}"
|
186
199
|
# Create target directory if it does not exist.
|