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
ramifice/fields/date_field.py
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
"""Field of Model for enter date."""
|
1
|
+
"""Ramifice - Field of Model for enter date."""
|
2
2
|
|
3
3
|
__all__ = ("DateField",)
|
4
4
|
|
5
|
+
import logging
|
5
6
|
from datetime import datetime
|
6
7
|
from typing import Any
|
7
8
|
|
@@ -13,9 +14,11 @@ from ramifice.fields.general.date_group import DateGroup
|
|
13
14
|
from ramifice.fields.general.field import Field
|
14
15
|
from ramifice.utils import constants, translations
|
15
16
|
|
17
|
+
logger = logging.getLogger(__name__)
|
18
|
+
|
16
19
|
|
17
20
|
class DateField(Field, DateGroup):
|
18
|
-
"""Field of Model for enter date."""
|
21
|
+
"""Ramifice - Field of Model for enter date."""
|
19
22
|
|
20
23
|
def __init__( # noqa: D107
|
21
24
|
self,
|
@@ -33,41 +36,47 @@ class DateField(Field, DateGroup):
|
|
33
36
|
min_date: datetime | None = None,
|
34
37
|
):
|
35
38
|
if constants.DEBUG:
|
36
|
-
|
37
|
-
if not
|
38
|
-
|
39
|
-
|
40
|
-
if not
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
39
|
+
try:
|
40
|
+
if max_date is not None:
|
41
|
+
if not isinstance(max_date, datetime):
|
42
|
+
raise AssertionError("Parameter `max_date` - Not а `str` type!")
|
43
|
+
if min_date is not None:
|
44
|
+
if not isinstance(min_date, datetime):
|
45
|
+
raise AssertionError("Parameter `min_date` - Not а `str` type!")
|
46
|
+
if max_date is not None and min_date is not None and max_date <= min_date:
|
47
|
+
raise AssertionError(
|
48
|
+
"The `max_date` parameter should be more than the `min_date`!"
|
49
|
+
)
|
50
|
+
if default is not None:
|
51
|
+
if not isinstance(default, datetime):
|
52
|
+
raise AssertionError("Parameter `default` - Not а `str` type!")
|
53
|
+
if max_date is not None and default > max_date:
|
54
|
+
raise AssertionError("Parameter `default` is more `max_date`!")
|
55
|
+
if min_date is not None and default < min_date:
|
56
|
+
raise AssertionError("Parameter `default` is less `min_date`!")
|
57
|
+
if not isinstance(label, str):
|
46
58
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
47
|
-
if
|
48
|
-
raise AssertionError("Parameter `
|
49
|
-
if
|
50
|
-
raise AssertionError("Parameter `
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
raise AssertionError("Parameter `required` - Not а `bool` type!")
|
69
|
-
if not isinstance(readonly, bool):
|
70
|
-
raise AssertionError("Parameter `readonly` - Not а `bool` type!")
|
59
|
+
if not isinstance(disabled, bool):
|
60
|
+
raise AssertionError("Parameter `disabled` - Not а `bool` type!")
|
61
|
+
if not isinstance(hide, bool):
|
62
|
+
raise AssertionError("Parameter `hide` - Not а `bool` type!")
|
63
|
+
if not isinstance(ignored, bool):
|
64
|
+
raise AssertionError("Parameter `ignored` - Not а `bool` type!")
|
65
|
+
if not isinstance(ignored, bool):
|
66
|
+
raise AssertionError("Parameter `ignored` - Not а `bool` type!")
|
67
|
+
if not isinstance(hint, str):
|
68
|
+
raise AssertionError("Parameter `hint` - Not а `str` type!")
|
69
|
+
if warning is not None and not isinstance(warning, list):
|
70
|
+
raise AssertionError("Parameter `warning` - Not а `list` type!")
|
71
|
+
if not isinstance(placeholder, str):
|
72
|
+
raise AssertionError("Parameter `placeholder` - Not а `str` type!")
|
73
|
+
if not isinstance(required, bool):
|
74
|
+
raise AssertionError("Parameter `required` - Not а `bool` type!")
|
75
|
+
if not isinstance(readonly, bool):
|
76
|
+
raise AssertionError("Parameter `readonly` - Not а `bool` type!")
|
77
|
+
except AssertionError as err:
|
78
|
+
logger.error(str(err))
|
79
|
+
raise err
|
71
80
|
|
72
81
|
Field.__init__(
|
73
82
|
self,
|
@@ -94,7 +103,7 @@ class DateField(Field, DateGroup):
|
|
94
103
|
self.default = default
|
95
104
|
|
96
105
|
def to_dict(self) -> dict[str, Any]:
|
97
|
-
"""Convert object instance to a dictionary."""
|
106
|
+
"""Ramifice - Convert object instance to a dictionary."""
|
98
107
|
json_dict: dict[str, Any] = {}
|
99
108
|
current_locale = translations.CURRENT_LOCALE
|
100
109
|
for name, value in self.__dict__.items():
|
@@ -110,12 +119,12 @@ class DateField(Field, DateGroup):
|
|
110
119
|
return json_dict
|
111
120
|
|
112
121
|
def to_json(self) -> str:
|
113
|
-
"""Convert object instance to a JSON string."""
|
122
|
+
"""Ramifice - Convert object instance to a JSON string."""
|
114
123
|
return orjson.dumps(self.to_dict()).decode("utf-8")
|
115
124
|
|
116
125
|
@classmethod
|
117
126
|
def from_dict(cls, json_dict: dict[str, Any]) -> Any:
|
118
|
-
"""Convert JSON string to a object instance."""
|
127
|
+
"""Ramifice - Convert JSON string to a object instance."""
|
119
128
|
obj = cls()
|
120
129
|
for name, value in json_dict.items():
|
121
130
|
if name == "value" and value is not None:
|
@@ -126,6 +135,6 @@ class DateField(Field, DateGroup):
|
|
126
135
|
|
127
136
|
@classmethod
|
128
137
|
def from_json(cls, json_str: str) -> Any:
|
129
|
-
"""Convert JSON string to a object instance."""
|
138
|
+
"""Ramifice - Convert JSON string to a object instance."""
|
130
139
|
json_dict = orjson.loads(json_str)
|
131
140
|
return cls.from_dict(json_dict)
|
@@ -1,7 +1,8 @@
|
|
1
|
-
"""Field of Model for enter date and time."""
|
1
|
+
"""Ramifice - Field of Model for enter date and time."""
|
2
2
|
|
3
3
|
__all__ = ("DateTimeField",)
|
4
4
|
|
5
|
+
import logging
|
5
6
|
from datetime import datetime
|
6
7
|
from typing import Any
|
7
8
|
|
@@ -13,9 +14,11 @@ from ramifice.fields.general.date_group import DateGroup
|
|
13
14
|
from ramifice.fields.general.field import Field
|
14
15
|
from ramifice.utils import constants, translations
|
15
16
|
|
17
|
+
logger = logging.getLogger(__name__)
|
18
|
+
|
16
19
|
|
17
20
|
class DateTimeField(Field, DateGroup):
|
18
|
-
"""Field of Model for enter date and time."""
|
21
|
+
"""Ramifice - Field of Model for enter date and time."""
|
19
22
|
|
20
23
|
def __init__( # noqa: D107
|
21
24
|
self,
|
@@ -33,41 +36,47 @@ class DateTimeField(Field, DateGroup):
|
|
33
36
|
min_date: datetime | None = None,
|
34
37
|
):
|
35
38
|
if constants.DEBUG:
|
36
|
-
|
37
|
-
if not
|
38
|
-
|
39
|
-
|
40
|
-
if not
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
39
|
+
try:
|
40
|
+
if max_date is not None:
|
41
|
+
if not isinstance(max_date, datetime):
|
42
|
+
raise AssertionError("Parameter `max_date` - Not а `str` type!")
|
43
|
+
if min_date is not None:
|
44
|
+
if not isinstance(min_date, datetime):
|
45
|
+
raise AssertionError("Parameter `min_date` - Not а `str` type!")
|
46
|
+
if max_date is not None and min_date is not None and max_date <= min_date:
|
47
|
+
raise AssertionError(
|
48
|
+
"The `max_date` parameter should be more than the `min_date`!"
|
49
|
+
)
|
50
|
+
if default is not None:
|
51
|
+
if not isinstance(default, datetime):
|
52
|
+
raise AssertionError("Parameter `default` - Not а `str` type!")
|
53
|
+
if max_date is not None and default > max_date:
|
54
|
+
raise AssertionError("Parameter `default` is more `max_date`!")
|
55
|
+
if min_date is not None and default < min_date:
|
56
|
+
raise AssertionError("Parameter `default` is less `min_date`!")
|
57
|
+
if not isinstance(label, str):
|
46
58
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
47
|
-
if
|
48
|
-
raise AssertionError("Parameter `
|
49
|
-
if
|
50
|
-
raise AssertionError("Parameter `
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
raise AssertionError("Parameter `required` - Not а `bool` type!")
|
69
|
-
if not isinstance(readonly, bool):
|
70
|
-
raise AssertionError("Parameter `readonly` - Not а `bool` type!")
|
59
|
+
if not isinstance(disabled, bool):
|
60
|
+
raise AssertionError("Parameter `disabled` - Not а `bool` type!")
|
61
|
+
if not isinstance(hide, bool):
|
62
|
+
raise AssertionError("Parameter `hide` - Not а `bool` type!")
|
63
|
+
if not isinstance(ignored, bool):
|
64
|
+
raise AssertionError("Parameter `ignored` - Not а `bool` type!")
|
65
|
+
if not isinstance(ignored, bool):
|
66
|
+
raise AssertionError("Parameter `ignored` - Not а `bool` type!")
|
67
|
+
if not isinstance(hint, str):
|
68
|
+
raise AssertionError("Parameter `hint` - Not а `str` type!")
|
69
|
+
if warning is not None and not isinstance(warning, list):
|
70
|
+
raise AssertionError("Parameter `warning` - Not а `list` type!")
|
71
|
+
if not isinstance(placeholder, str):
|
72
|
+
raise AssertionError("Parameter `placeholder` - Not а `str` type!")
|
73
|
+
if not isinstance(required, bool):
|
74
|
+
raise AssertionError("Parameter `required` - Not а `bool` type!")
|
75
|
+
if not isinstance(readonly, bool):
|
76
|
+
raise AssertionError("Parameter `readonly` - Not а `bool` type!")
|
77
|
+
except AssertionError as err:
|
78
|
+
logger.error(str(err))
|
79
|
+
raise err
|
71
80
|
|
72
81
|
Field.__init__(
|
73
82
|
self,
|
@@ -94,7 +103,7 @@ class DateTimeField(Field, DateGroup):
|
|
94
103
|
self.default = default
|
95
104
|
|
96
105
|
def to_dict(self) -> dict[str, Any]:
|
97
|
-
"""Convert object instance to a dictionary."""
|
106
|
+
"""Ramifice - Convert object instance to a dictionary."""
|
98
107
|
json_dict: dict[str, Any] = {}
|
99
108
|
current_locale = translations.CURRENT_LOCALE
|
100
109
|
for name, value in self.__dict__.items():
|
@@ -110,12 +119,12 @@ class DateTimeField(Field, DateGroup):
|
|
110
119
|
return json_dict
|
111
120
|
|
112
121
|
def to_json(self) -> str:
|
113
|
-
"""Convert object instance to a JSON string."""
|
122
|
+
"""Ramifice - Convert object instance to a JSON string."""
|
114
123
|
return orjson.dumps(self.to_dict()).decode("utf-8")
|
115
124
|
|
116
125
|
@classmethod
|
117
126
|
def from_dict(cls, json_dict: dict[str, Any]) -> Any:
|
118
|
-
"""Convert JSON string to a object instance."""
|
127
|
+
"""Ramifice - Convert JSON string to a object instance."""
|
119
128
|
obj = cls()
|
120
129
|
for name, value in json_dict.items():
|
121
130
|
if name == "value" and value is not None:
|
@@ -126,6 +135,6 @@ class DateTimeField(Field, DateGroup):
|
|
126
135
|
|
127
136
|
@classmethod
|
128
137
|
def from_json(cls, json_str: str) -> Any:
|
129
|
-
"""Convert JSON string to a object instance."""
|
138
|
+
"""Ramifice - Convert JSON string to a object instance."""
|
130
139
|
json_dict = orjson.loads(json_str)
|
131
140
|
return cls.from_dict(json_dict)
|
ramifice/fields/email_field.py
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
"""Field of Model for enter email address."""
|
1
|
+
"""Ramifice - Field of Model for enter email address."""
|
2
2
|
|
3
3
|
__all__ = ("EmailField",)
|
4
4
|
|
5
|
+
import logging
|
6
|
+
|
5
7
|
from email_validator import EmailNotValidError, validate_email
|
6
8
|
|
7
9
|
from ramifice.fields.general.field import Field
|
@@ -9,9 +11,11 @@ from ramifice.fields.general.text_group import TextGroup
|
|
9
11
|
from ramifice.utils import constants
|
10
12
|
from ramifice.utils.mixins.json_converter import JsonMixin
|
11
13
|
|
14
|
+
logger = logging.getLogger(__name__)
|
15
|
+
|
12
16
|
|
13
17
|
class EmailField(Field, TextGroup, JsonMixin):
|
14
|
-
"""Field of Model for enter email address."""
|
18
|
+
"""Ramifice - Field of Model for enter email address."""
|
15
19
|
|
16
20
|
def __init__( # noqa: D107
|
17
21
|
self,
|
@@ -28,39 +32,43 @@ class EmailField(Field, TextGroup, JsonMixin):
|
|
28
32
|
unique: bool = False,
|
29
33
|
):
|
30
34
|
if constants.DEBUG:
|
31
|
-
|
32
|
-
if not
|
35
|
+
try:
|
36
|
+
if default is not None:
|
37
|
+
if not isinstance(default, str):
|
38
|
+
raise AssertionError("Parameter `default` - Not а `str` type!")
|
39
|
+
if len(default) == 0:
|
40
|
+
raise AssertionError(
|
41
|
+
"The `default` parameter should not contain an empty string!"
|
42
|
+
)
|
43
|
+
try:
|
44
|
+
validate_email(default, check_deliverability=True)
|
45
|
+
except EmailNotValidError:
|
46
|
+
raise AssertionError("Parameter `default` - Invalid Email address!")
|
47
|
+
if not isinstance(label, str):
|
33
48
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
34
|
-
if
|
35
|
-
raise AssertionError(
|
36
|
-
|
37
|
-
)
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
raise AssertionError("Parameter `
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
raise AssertionError("Parameter `placeholder` - Not а `str` type!")
|
58
|
-
if not isinstance(required, bool):
|
59
|
-
raise AssertionError("Parameter `required` - Not а `bool` type!")
|
60
|
-
if not isinstance(readonly, bool):
|
61
|
-
raise AssertionError("Parameter `readonly` - Not а `bool` type!")
|
62
|
-
if not isinstance(unique, bool):
|
63
|
-
raise AssertionError("Parameter `unique` - Not а `bool` type!")
|
49
|
+
if not isinstance(disabled, bool):
|
50
|
+
raise AssertionError("Parameter `disabled` - Not а `bool` type!")
|
51
|
+
if not isinstance(hide, bool):
|
52
|
+
raise AssertionError("Parameter `hide` - Not а `bool` type!")
|
53
|
+
if not isinstance(ignored, bool):
|
54
|
+
raise AssertionError("Parameter `ignored` - Not а `bool` type!")
|
55
|
+
if not isinstance(ignored, bool):
|
56
|
+
raise AssertionError("Parameter `ignored` - Not а `bool` type!")
|
57
|
+
if not isinstance(hint, str):
|
58
|
+
raise AssertionError("Parameter `hint` - Not а `str` type!")
|
59
|
+
if warning is not None and not isinstance(warning, list):
|
60
|
+
raise AssertionError("Parameter `warning` - Not а `list` type!")
|
61
|
+
if not isinstance(placeholder, str):
|
62
|
+
raise AssertionError("Parameter `placeholder` - Not а `str` type!")
|
63
|
+
if not isinstance(required, bool):
|
64
|
+
raise AssertionError("Parameter `required` - Not а `bool` type!")
|
65
|
+
if not isinstance(readonly, bool):
|
66
|
+
raise AssertionError("Parameter `readonly` - Not а `bool` type!")
|
67
|
+
if not isinstance(unique, bool):
|
68
|
+
raise AssertionError("Parameter `unique` - Not а `bool` type!")
|
69
|
+
except AssertionError as err:
|
70
|
+
logger.error(str(err))
|
71
|
+
raise err
|
64
72
|
|
65
73
|
Field.__init__(
|
66
74
|
self,
|
ramifice/fields/file_field.py
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
"""Field of Model for upload file."""
|
1
|
+
"""Ramifice - Field of Model for upload file."""
|
2
2
|
|
3
3
|
__all__ = ("FileField",)
|
4
4
|
|
5
|
+
import logging
|
5
6
|
import uuid
|
6
7
|
from base64 import b64decode
|
7
8
|
from datetime import date
|
@@ -18,9 +19,11 @@ from ramifice.utils.constants import MEDIA_ROOT, MEDIA_URL
|
|
18
19
|
from ramifice.utils.errors import FileHasNoExtensionError
|
19
20
|
from ramifice.utils.mixins.json_converter import JsonMixin
|
20
21
|
|
22
|
+
logger = logging.getLogger(__name__)
|
23
|
+
|
21
24
|
|
22
25
|
class FileField(Field, FileGroup, JsonMixin):
|
23
|
-
"""Field of Model for upload file."""
|
26
|
+
"""Ramifice - Field of Model for upload file."""
|
24
27
|
|
25
28
|
def __init__( # noqa: D107
|
26
29
|
self,
|
@@ -39,37 +42,41 @@ class FileField(Field, FileGroup, JsonMixin):
|
|
39
42
|
accept: str = "",
|
40
43
|
):
|
41
44
|
if constants.DEBUG:
|
42
|
-
|
43
|
-
if not
|
45
|
+
try:
|
46
|
+
if default is not None:
|
47
|
+
if not isinstance(default, str):
|
48
|
+
raise AssertionError("Parameter `default` - Not а `str` type!")
|
49
|
+
if len(default) == 0:
|
50
|
+
raise AssertionError(
|
51
|
+
"The `default` parameter should not contain an empty string!"
|
52
|
+
)
|
53
|
+
if not isinstance(label, str):
|
44
54
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
45
|
-
if
|
46
|
-
raise AssertionError(
|
47
|
-
|
48
|
-
)
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
raise AssertionError("Parameter `target_dir` - Not а `str` type!")
|
71
|
-
if not isinstance(accept, str):
|
72
|
-
raise AssertionError("Parameter `accept` - Not а `str` type!")
|
55
|
+
if not isinstance(disabled, bool):
|
56
|
+
raise AssertionError("Parameter `disabled` - Not а `bool` type!")
|
57
|
+
if not isinstance(hide, bool):
|
58
|
+
raise AssertionError("Parameter `hide` - Not а `bool` type!")
|
59
|
+
if not isinstance(ignored, bool):
|
60
|
+
raise AssertionError("Parameter `ignored` - Not а `bool` type!")
|
61
|
+
if not isinstance(ignored, bool):
|
62
|
+
raise AssertionError("Parameter `ignored` - Not а `bool` type!")
|
63
|
+
if not isinstance(hint, str):
|
64
|
+
raise AssertionError("Parameter `hint` - Not а `str` type!")
|
65
|
+
if warning is not None and not isinstance(warning, list):
|
66
|
+
raise AssertionError("Parameter `warning` - Not а `list` type!")
|
67
|
+
if not isinstance(placeholder, str):
|
68
|
+
raise AssertionError("Parameter `placeholder` - Not а `str` type!")
|
69
|
+
if not isinstance(required, bool):
|
70
|
+
raise AssertionError("Parameter `required` - Not а `bool` type!")
|
71
|
+
if not isinstance(max_size, int):
|
72
|
+
raise AssertionError("Parameter `max_size` - Not а `int` type!")
|
73
|
+
if not isinstance(target_dir, str):
|
74
|
+
raise AssertionError("Parameter `target_dir` - Not а `str` type!")
|
75
|
+
if not isinstance(accept, str):
|
76
|
+
raise AssertionError("Parameter `accept` - Not а `str` type!")
|
77
|
+
except AssertionError as err:
|
78
|
+
logger.error(str(err))
|
79
|
+
raise err
|
73
80
|
|
74
81
|
Field.__init__(
|
75
82
|
self,
|
@@ -101,7 +108,7 @@ class FileField(Field, FileGroup, JsonMixin):
|
|
101
108
|
filename: str | None = None,
|
102
109
|
is_delete: bool = False,
|
103
110
|
) -> None:
|
104
|
-
"""Convert base64 to a file,
|
111
|
+
"""Ramifice - Convert base64 to a file,
|
105
112
|
get file information and save in the target directory.
|
106
113
|
""" # noqa: D205
|
107
114
|
base64_str = base64_str or None
|
@@ -114,7 +121,9 @@ class FileField(Field, FileGroup, JsonMixin):
|
|
114
121
|
# Get file extension.
|
115
122
|
extension = Path(filename).suffix
|
116
123
|
if len(extension) == 0:
|
117
|
-
|
124
|
+
msg = f"The file `{filename}` has no extension."
|
125
|
+
logger.error(msg)
|
126
|
+
raise FileHasNoExtensionError(msg)
|
118
127
|
# Prepare Base64 content.
|
119
128
|
for item in enumerate(base64_str):
|
120
129
|
if item[1] == ",":
|
@@ -155,7 +164,7 @@ class FileField(Field, FileGroup, JsonMixin):
|
|
155
164
|
src_path: str | None = None,
|
156
165
|
is_delete: bool = False,
|
157
166
|
) -> None:
|
158
|
-
"""Get file information and copy the file to the target directory."""
|
167
|
+
"""Ramifice - Get file information and copy the file to the target directory."""
|
159
168
|
src_path = src_path or None
|
160
169
|
file_info: dict[str, str | int | bool] = {"save_as_is": False}
|
161
170
|
file_info["is_new_file"] = True
|
@@ -166,6 +175,7 @@ class FileField(Field, FileGroup, JsonMixin):
|
|
166
175
|
extension = Path(src_path).suffix
|
167
176
|
if len(extension) == 0:
|
168
177
|
msg = f"The file `{src_path}` has no extension."
|
178
|
+
logger.error(msg)
|
169
179
|
raise FileHasNoExtensionError(msg)
|
170
180
|
# Create new (uuid) file name.
|
171
181
|
f_uuid_name = f"{uuid.uuid4()}{extension}"
|