ramifice 0.8.21__py3-none-any.whl → 0.8.25__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 +4 -4
- ramifice/fields/choice_float_dyn_field.py +5 -5
- ramifice/fields/choice_float_field.py +5 -5
- ramifice/fields/choice_float_mult_dyn_field.py +5 -5
- ramifice/fields/choice_float_mult_field.py +5 -5
- ramifice/fields/choice_int_dyn_field.py +5 -5
- ramifice/fields/choice_int_field.py +5 -5
- ramifice/fields/choice_int_mult_dyn_field.py +5 -5
- ramifice/fields/choice_int_mult_field.py +5 -5
- ramifice/fields/choice_text_dyn_field.py +5 -5
- ramifice/fields/choice_text_field.py +5 -5
- ramifice/fields/choice_text_mult_dyn_field.py +5 -5
- ramifice/fields/choice_text_mult_field.py +5 -5
- ramifice/fields/color_field.py +4 -4
- ramifice/fields/date_field.py +7 -7
- ramifice/fields/date_time_field.py +7 -7
- ramifice/fields/email_field.py +4 -4
- ramifice/fields/file_field.py +6 -6
- ramifice/fields/float_field.py +4 -4
- 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 +7 -7
- ramifice/fields/image_field.py +6 -6
- ramifice/fields/integer_field.py +4 -4
- ramifice/fields/ip_field.py +4 -4
- ramifice/fields/password_field.py +7 -7
- ramifice/fields/phone_field.py +4 -4
- ramifice/fields/slug_field.py +4 -4
- ramifice/fields/text_field.py +5 -5
- ramifice/fields/url_field.py +4 -4
- ramifice/models/__init__.py +1 -1
- ramifice/models/decorator.py +3 -3
- ramifice/models/model.py +16 -16
- ramifice/paladins/__init__.py +2 -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.21.dist-info → ramifice-0.8.25.dist-info}/METADATA +3 -2
- ramifice-0.8.25.dist-info/RECORD +83 -0
- ramifice/utils/mixins/__init__.py +0 -5
- ramifice-0.8.21.dist-info/RECORD +0 -84
- {ramifice-0.8.21.dist-info → ramifice-0.8.25.dist-info}/WHEEL +0 -0
- {ramifice-0.8.21.dist-info → ramifice-0.8.25.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,13 +10,13 @@ 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.
|
@@ -32,7 +32,7 @@ class ChoiceIntMultDynField(Field, ChoiceGroup, JsonMixin):
|
|
32
32
|
warning: list[str] | None = None,
|
33
33
|
required: bool = False,
|
34
34
|
readonly: bool = False,
|
35
|
-
):
|
35
|
+
) -> None:
|
36
36
|
if constants.DEBUG:
|
37
37
|
try:
|
38
38
|
if not isinstance(label, str):
|
@@ -80,7 +80,7 @@ class ChoiceIntMultDynField(Field, ChoiceGroup, JsonMixin):
|
|
80
80
|
self.choices: list[list[int | str]] | None = None
|
81
81
|
|
82
82
|
def has_value(self, is_migrate: bool = False) -> bool:
|
83
|
-
"""
|
83
|
+
"""Does the field value match the possible options in choices."""
|
84
84
|
if is_migrate:
|
85
85
|
return True
|
86
86
|
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,13 +10,13 @@ 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.
|
@@ -34,7 +34,7 @@ class ChoiceIntMultField(Field, ChoiceGroup, JsonMixin):
|
|
34
34
|
required: bool = False,
|
35
35
|
readonly: bool = False,
|
36
36
|
choices: list[list[int | str]] | None = None,
|
37
|
-
):
|
37
|
+
) -> None:
|
38
38
|
Field.__init__(
|
39
39
|
self,
|
40
40
|
label=label,
|
@@ -102,7 +102,7 @@ class ChoiceIntMultField(Field, ChoiceGroup, JsonMixin):
|
|
102
102
|
raise err
|
103
103
|
|
104
104
|
def has_value(self, is_migrate: bool = False) -> bool:
|
105
|
-
"""
|
105
|
+
"""Does the field value match the possible options in choices."""
|
106
106
|
value = self.value
|
107
107
|
if value is None:
|
108
108
|
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,13 +10,13 @@ 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.
|
@@ -33,7 +33,7 @@ class ChoiceTextDynField(Field, ChoiceGroup, JsonMixin):
|
|
33
33
|
warning: list[str] | None = None,
|
34
34
|
required: bool = False,
|
35
35
|
readonly: bool = False,
|
36
|
-
):
|
36
|
+
) -> None:
|
37
37
|
if constants.DEBUG:
|
38
38
|
try:
|
39
39
|
if not isinstance(label, str):
|
@@ -80,7 +80,7 @@ class ChoiceTextDynField(Field, ChoiceGroup, JsonMixin):
|
|
80
80
|
self.choices: list[list[str]] | None = None
|
81
81
|
|
82
82
|
def has_value(self, is_migrate: bool = False) -> bool:
|
83
|
-
"""
|
83
|
+
"""Does the field value match the possible options in choices."""
|
84
84
|
if is_migrate:
|
85
85
|
return True
|
86
86
|
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,13 +10,13 @@ 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.
|
@@ -34,7 +34,7 @@ class ChoiceTextField(Field, ChoiceGroup, JsonMixin):
|
|
34
34
|
required: bool = False,
|
35
35
|
readonly: bool = False,
|
36
36
|
choices: list[list[str]] | None = None,
|
37
|
-
):
|
37
|
+
) -> None:
|
38
38
|
Field.__init__(
|
39
39
|
self,
|
40
40
|
label=label,
|
@@ -101,7 +101,7 @@ class ChoiceTextField(Field, ChoiceGroup, JsonMixin):
|
|
101
101
|
raise err
|
102
102
|
|
103
103
|
def has_value(self, is_migrate: bool = False) -> bool:
|
104
|
-
"""
|
104
|
+
"""Does the field value match the possible options in choices."""
|
105
105
|
value = self.value
|
106
106
|
if value is None:
|
107
107
|
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,13 +10,13 @@ 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.
|
@@ -32,7 +32,7 @@ class ChoiceTextMultDynField(Field, ChoiceGroup, JsonMixin):
|
|
32
32
|
warning: list[str] | None = None,
|
33
33
|
required: bool = False,
|
34
34
|
readonly: bool = False,
|
35
|
-
):
|
35
|
+
) -> None:
|
36
36
|
if constants.DEBUG:
|
37
37
|
try:
|
38
38
|
if not isinstance(label, str):
|
@@ -80,7 +80,7 @@ class ChoiceTextMultDynField(Field, ChoiceGroup, JsonMixin):
|
|
80
80
|
self.choices: list[list[str]] | None = None
|
81
81
|
|
82
82
|
def has_value(self, is_migrate: bool = False) -> bool:
|
83
|
-
"""
|
83
|
+
"""Does the field value match the possible options in choices."""
|
84
84
|
if is_migrate:
|
85
85
|
return True
|
86
86
|
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,13 +10,13 @@ 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.
|
@@ -34,7 +34,7 @@ class ChoiceTextMultField(Field, ChoiceGroup, JsonMixin):
|
|
34
34
|
required: bool = False,
|
35
35
|
readonly: bool = False,
|
36
36
|
choices: list[list[str]] | None = None,
|
37
|
-
):
|
37
|
+
) -> None:
|
38
38
|
Field.__init__(
|
39
39
|
self,
|
40
40
|
label=label,
|
@@ -102,7 +102,7 @@ class ChoiceTextMultField(Field, ChoiceGroup, JsonMixin):
|
|
102
102
|
raise err
|
103
103
|
|
104
104
|
def has_value(self, is_migrate: bool = False) -> bool:
|
105
|
-
"""
|
105
|
+
"""Does the field value match the possible options in choices."""
|
106
106
|
value = self.value
|
107
107
|
if value is None:
|
108
108
|
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,13 +7,13 @@ 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
|
|
@@ -36,7 +36,7 @@ class ColorField(Field, TextGroup, JsonMixin):
|
|
36
36
|
required: bool = False,
|
37
37
|
readonly: bool = False,
|
38
38
|
unique: bool = False,
|
39
|
-
):
|
39
|
+
) -> None:
|
40
40
|
if constants.DEBUG:
|
41
41
|
try:
|
42
42
|
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,7 +18,7 @@ logger = logging.getLogger(__name__)
|
|
18
18
|
|
19
19
|
|
20
20
|
class DateField(Field, DateGroup):
|
21
|
-
"""
|
21
|
+
"""Field of Model for enter date."""
|
22
22
|
|
23
23
|
def __init__( # noqa: D107
|
24
24
|
self,
|
@@ -34,7 +34,7 @@ class DateField(Field, DateGroup):
|
|
34
34
|
readonly: bool = False,
|
35
35
|
max_date: datetime | None = None,
|
36
36
|
min_date: datetime | None = None,
|
37
|
-
):
|
37
|
+
) -> None:
|
38
38
|
if constants.DEBUG:
|
39
39
|
try:
|
40
40
|
if max_date is not None:
|
@@ -103,7 +103,7 @@ class DateField(Field, DateGroup):
|
|
103
103
|
self.default = default
|
104
104
|
|
105
105
|
def to_dict(self) -> dict[str, Any]:
|
106
|
-
"""
|
106
|
+
"""Convert object instance to a dictionary."""
|
107
107
|
json_dict: dict[str, Any] = {}
|
108
108
|
current_locale = translations.CURRENT_LOCALE
|
109
109
|
for name, value in self.__dict__.items():
|
@@ -119,12 +119,12 @@ class DateField(Field, DateGroup):
|
|
119
119
|
return json_dict
|
120
120
|
|
121
121
|
def to_json(self) -> str:
|
122
|
-
"""
|
122
|
+
"""Convert object instance to a JSON string."""
|
123
123
|
return orjson.dumps(self.to_dict()).decode("utf-8")
|
124
124
|
|
125
125
|
@classmethod
|
126
126
|
def from_dict(cls, json_dict: dict[str, Any]) -> Any:
|
127
|
-
"""
|
127
|
+
"""Convert JSON string to a object instance."""
|
128
128
|
obj = cls()
|
129
129
|
for name, value in json_dict.items():
|
130
130
|
if name == "value" and value is not None:
|
@@ -135,6 +135,6 @@ class DateField(Field, DateGroup):
|
|
135
135
|
|
136
136
|
@classmethod
|
137
137
|
def from_json(cls, json_str: str) -> Any:
|
138
|
-
"""
|
138
|
+
"""Convert JSON string to a object instance."""
|
139
139
|
json_dict = orjson.loads(json_str)
|
140
140
|
return cls.from_dict(json_dict)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Field of Model for enter date and time."""
|
2
2
|
|
3
3
|
__all__ = ("DateTimeField",)
|
4
4
|
|
@@ -18,7 +18,7 @@ logger = logging.getLogger(__name__)
|
|
18
18
|
|
19
19
|
|
20
20
|
class DateTimeField(Field, DateGroup):
|
21
|
-
"""
|
21
|
+
"""Field of Model for enter date and time."""
|
22
22
|
|
23
23
|
def __init__( # noqa: D107
|
24
24
|
self,
|
@@ -34,7 +34,7 @@ class DateTimeField(Field, DateGroup):
|
|
34
34
|
readonly: bool = False,
|
35
35
|
max_date: datetime | None = None,
|
36
36
|
min_date: datetime | None = None,
|
37
|
-
):
|
37
|
+
) -> None:
|
38
38
|
if constants.DEBUG:
|
39
39
|
try:
|
40
40
|
if max_date is not None:
|
@@ -103,7 +103,7 @@ class DateTimeField(Field, DateGroup):
|
|
103
103
|
self.default = default
|
104
104
|
|
105
105
|
def to_dict(self) -> dict[str, Any]:
|
106
|
-
"""
|
106
|
+
"""Convert object instance to a dictionary."""
|
107
107
|
json_dict: dict[str, Any] = {}
|
108
108
|
current_locale = translations.CURRENT_LOCALE
|
109
109
|
for name, value in self.__dict__.items():
|
@@ -119,12 +119,12 @@ class DateTimeField(Field, DateGroup):
|
|
119
119
|
return json_dict
|
120
120
|
|
121
121
|
def to_json(self) -> str:
|
122
|
-
"""
|
122
|
+
"""Convert object instance to a JSON string."""
|
123
123
|
return orjson.dumps(self.to_dict()).decode("utf-8")
|
124
124
|
|
125
125
|
@classmethod
|
126
126
|
def from_dict(cls, json_dict: dict[str, Any]) -> Any:
|
127
|
-
"""
|
127
|
+
"""Convert JSON string to a object instance."""
|
128
128
|
obj = cls()
|
129
129
|
for name, value in json_dict.items():
|
130
130
|
if name == "value" and value is not None:
|
@@ -135,6 +135,6 @@ class DateTimeField(Field, DateGroup):
|
|
135
135
|
|
136
136
|
@classmethod
|
137
137
|
def from_json(cls, json_str: str) -> Any:
|
138
|
-
"""
|
138
|
+
"""Convert JSON string to a object instance."""
|
139
139
|
json_dict = orjson.loads(json_str)
|
140
140
|
return cls.from_dict(json_dict)
|
ramifice/fields/email_field.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Field of Model for enter email address."""
|
2
2
|
|
3
3
|
__all__ = ("EmailField",)
|
4
4
|
|
@@ -9,13 +9,13 @@ from email_validator import EmailNotValidError, validate_email
|
|
9
9
|
from ramifice.fields.general.field import Field
|
10
10
|
from ramifice.fields.general.text_group import TextGroup
|
11
11
|
from ramifice.utils import constants
|
12
|
-
from ramifice.utils.mixins
|
12
|
+
from ramifice.utils.mixins import JsonMixin
|
13
13
|
|
14
14
|
logger = logging.getLogger(__name__)
|
15
15
|
|
16
16
|
|
17
17
|
class EmailField(Field, TextGroup, JsonMixin):
|
18
|
-
"""
|
18
|
+
"""Field of Model for enter email address."""
|
19
19
|
|
20
20
|
def __init__( # noqa: D107
|
21
21
|
self,
|
@@ -30,7 +30,7 @@ class EmailField(Field, TextGroup, JsonMixin):
|
|
30
30
|
required: bool = False,
|
31
31
|
readonly: bool = False,
|
32
32
|
unique: bool = False,
|
33
|
-
):
|
33
|
+
) -> None:
|
34
34
|
if constants.DEBUG:
|
35
35
|
try:
|
36
36
|
if default is not None:
|
ramifice/fields/file_field.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Field of Model for upload file."""
|
2
2
|
|
3
3
|
__all__ = ("FileField",)
|
4
4
|
|
@@ -17,13 +17,13 @@ from ramifice.fields.general.file_group import FileGroup
|
|
17
17
|
from ramifice.utils import constants
|
18
18
|
from ramifice.utils.constants import MEDIA_ROOT, MEDIA_URL
|
19
19
|
from ramifice.utils.errors import FileHasNoExtensionError
|
20
|
-
from ramifice.utils.mixins
|
20
|
+
from ramifice.utils.mixins import JsonMixin
|
21
21
|
|
22
22
|
logger = logging.getLogger(__name__)
|
23
23
|
|
24
24
|
|
25
25
|
class FileField(Field, FileGroup, JsonMixin):
|
26
|
-
"""
|
26
|
+
"""Field of Model for upload file."""
|
27
27
|
|
28
28
|
def __init__( # noqa: D107
|
29
29
|
self,
|
@@ -40,7 +40,7 @@ class FileField(Field, FileGroup, JsonMixin):
|
|
40
40
|
placeholder: str = "",
|
41
41
|
target_dir: str = "files",
|
42
42
|
accept: str = "",
|
43
|
-
):
|
43
|
+
) -> None:
|
44
44
|
if constants.DEBUG:
|
45
45
|
try:
|
46
46
|
if default is not None:
|
@@ -108,7 +108,7 @@ class FileField(Field, FileGroup, JsonMixin):
|
|
108
108
|
filename: str | None = None,
|
109
109
|
is_delete: bool = False,
|
110
110
|
) -> None:
|
111
|
-
"""
|
111
|
+
"""Convert base64 to a file,
|
112
112
|
get file information and save in the target directory.
|
113
113
|
""" # noqa: D205
|
114
114
|
base64_str = base64_str or None
|
@@ -164,7 +164,7 @@ class FileField(Field, FileGroup, JsonMixin):
|
|
164
164
|
src_path: str | None = None,
|
165
165
|
is_delete: bool = False,
|
166
166
|
) -> None:
|
167
|
-
"""
|
167
|
+
"""Get file information and copy the file to the target directory."""
|
168
168
|
src_path = src_path or None
|
169
169
|
file_info: dict[str, str | int | bool] = {"save_as_is": False}
|
170
170
|
file_info["is_new_file"] = True
|
ramifice/fields/float_field.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Field of Model for enter (float) number."""
|
2
2
|
|
3
3
|
__all__ = ("FloatField",)
|
4
4
|
|
@@ -8,13 +8,13 @@ from typing import Literal
|
|
8
8
|
from ramifice.fields.general.field import Field
|
9
9
|
from ramifice.fields.general.number_group import NumberGroup
|
10
10
|
from ramifice.utils import constants
|
11
|
-
from ramifice.utils.mixins
|
11
|
+
from ramifice.utils.mixins import JsonMixin
|
12
12
|
|
13
13
|
logger = logging.getLogger(__name__)
|
14
14
|
|
15
15
|
|
16
16
|
class FloatField(Field, NumberGroup, JsonMixin):
|
17
|
-
"""
|
17
|
+
"""Field of Model for enter (float) number."""
|
18
18
|
|
19
19
|
def __init__( # noqa: D107
|
20
20
|
self,
|
@@ -33,7 +33,7 @@ class FloatField(Field, NumberGroup, JsonMixin):
|
|
33
33
|
min_number: float | None = None,
|
34
34
|
step: float = 1.0,
|
35
35
|
input_type: Literal["number", "range"] = "number",
|
36
|
-
):
|
36
|
+
) -> None:
|
37
37
|
if constants.DEBUG:
|
38
38
|
try:
|
39
39
|
if input_type not in ["number", "range"]:
|
@@ -1 +1 @@
|
|
1
|
-
"""
|
1
|
+
"""Abstract classes for the fields."""
|
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""General additional parameters for choice fields."""
|
2
2
|
|
3
3
|
__all__ = ("ChoiceGroup",)
|
4
4
|
|
@@ -6,15 +6,14 @@ from abc import ABCMeta
|
|
6
6
|
|
7
7
|
|
8
8
|
class ChoiceGroup(metaclass=ABCMeta):
|
9
|
-
"""
|
9
|
+
"""General additional parameters for choice fields.
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
multiple -- Specifies that multiple options can be selected at once.
|
11
|
+
Args:
|
12
|
+
placeholder: Displays prompt text.
|
13
|
+
required: Required field.
|
14
|
+
readonly: Specifies that the field cannot be modified by the user.
|
15
|
+
unique: The unique value of a field in a collection.
|
16
|
+
multiple: Specifies that multiple options can be selected at once.
|
18
17
|
"""
|
19
18
|
|
20
19
|
def __init__( # noqa: D107
|
@@ -24,7 +23,7 @@ class ChoiceGroup(metaclass=ABCMeta):
|
|
24
23
|
readonly: bool = False,
|
25
24
|
unique: bool = False,
|
26
25
|
multiple: bool = False,
|
27
|
-
):
|
26
|
+
) -> None:
|
28
27
|
self.placeholder = placeholder
|
29
28
|
self.required = required
|
30
29
|
self.readonly = readonly
|
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""General additional parameters for date|datetime fields."""
|
2
2
|
|
3
3
|
__all__ = ("DateGroup",)
|
4
4
|
|
@@ -7,16 +7,16 @@ from datetime import datetime
|
|
7
7
|
|
8
8
|
|
9
9
|
class DateGroup(metaclass=ABCMeta):
|
10
|
-
"""
|
10
|
+
"""General additional parameters for date|datetime fields.
|
11
11
|
|
12
|
-
|
13
|
-
input_type
|
14
|
-
placeholder
|
15
|
-
required
|
16
|
-
readonly
|
17
|
-
unique
|
18
|
-
max_date
|
19
|
-
min_date
|
12
|
+
Args:
|
13
|
+
input_type: Input type for a web form field.
|
14
|
+
placeholder: Displays prompt text.
|
15
|
+
required: Required field.
|
16
|
+
readonly: Specifies that the field cannot be modified by the user.
|
17
|
+
unique: The unique value of a field in a collection.
|
18
|
+
max_date: Maximum allowed date.
|
19
|
+
min_date: Minimum allowed date.
|
20
20
|
"""
|
21
21
|
|
22
22
|
def __init__( # noqa: D107
|
@@ -28,7 +28,7 @@ class DateGroup(metaclass=ABCMeta):
|
|
28
28
|
unique: bool = False,
|
29
29
|
max_date: datetime | None = None,
|
30
30
|
min_date: datetime | None = None,
|
31
|
-
):
|
31
|
+
) -> None:
|
32
32
|
self.input_type = input_type
|
33
33
|
self.value: datetime | None = None
|
34
34
|
self.placeholder = placeholder
|
ramifice/fields/general/field.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""General parameters for all types fields of Model."""
|
2
2
|
|
3
3
|
__all__ = ("Field",)
|
4
4
|
|
@@ -6,18 +6,18 @@ from abc import ABCMeta
|
|
6
6
|
|
7
7
|
|
8
8
|
class Field(metaclass=ABCMeta):
|
9
|
-
"""
|
9
|
+
"""General parameters for all types fields of Model.
|
10
10
|
|
11
|
-
|
12
|
-
label
|
13
|
-
disabled
|
14
|
-
hide
|
15
|
-
ignored
|
16
|
-
hint
|
17
|
-
warning
|
18
|
-
errors
|
19
|
-
field_type
|
20
|
-
group
|
11
|
+
Args:
|
12
|
+
label: Text label for a web form field.
|
13
|
+
disabled: Blocks access and modification of the element.
|
14
|
+
hide: Hide field from user.
|
15
|
+
ignored: If true, the value of this field is not saved in the database.
|
16
|
+
hint: An alternative for the `placeholder` parameter.
|
17
|
+
warning: Warning information.
|
18
|
+
errors: The value is determined automatically.
|
19
|
+
field_type: Field type - ClassName.
|
20
|
+
group: To optimize field traversal in the `check` method.
|
21
21
|
"""
|
22
22
|
|
23
23
|
def __init__( # noqa: D107
|
@@ -31,7 +31,7 @@ class Field(metaclass=ABCMeta):
|
|
31
31
|
errors: list[str] = [],
|
32
32
|
field_type: str = "",
|
33
33
|
group: str = "",
|
34
|
-
):
|
34
|
+
) -> None:
|
35
35
|
self.id = ""
|
36
36
|
self.label = label
|
37
37
|
self.name = ""
|
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""General additional parameters for file fields."""
|
2
2
|
|
3
3
|
__all__ = ("FileGroup",)
|
4
4
|
|
@@ -6,15 +6,15 @@ from abc import ABCMeta
|
|
6
6
|
|
7
7
|
|
8
8
|
class FileGroup(metaclass=ABCMeta):
|
9
|
-
"""
|
9
|
+
"""General additional parameters for file fields.
|
10
10
|
|
11
|
-
|
12
|
-
placeholder
|
13
|
-
required
|
14
|
-
max_size
|
15
|
-
default
|
16
|
-
target_dir
|
17
|
-
accept
|
11
|
+
Args:
|
12
|
+
placeholder: Displays prompt text.
|
13
|
+
required: Required field.
|
14
|
+
max_size: The maximum allowed file size in bytes.
|
15
|
+
default: Default file path.
|
16
|
+
target_dir: Directory for files inside media directory.
|
17
|
+
accept: Describing which file types to allow.
|
18
18
|
"""
|
19
19
|
|
20
20
|
def __init__( # noqa: D107
|
@@ -25,7 +25,7 @@ class FileGroup(metaclass=ABCMeta):
|
|
25
25
|
default: str | None = None,
|
26
26
|
target_dir: str = "",
|
27
27
|
accept: str = "",
|
28
|
-
):
|
28
|
+
) -> None:
|
29
29
|
self.input_type = "file"
|
30
30
|
self.placeholder = placeholder
|
31
31
|
self.required = required
|