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/fields/float_field.py
CHANGED
@@ -14,18 +14,36 @@ logger = logging.getLogger(__name__)
|
|
14
14
|
|
15
15
|
|
16
16
|
class FloatField(Field, NumberGroup, JsonMixin):
|
17
|
-
"""Field of Model for enter (float) number.
|
17
|
+
"""Field of Model for enter (float) number.
|
18
|
+
|
19
|
+
Agrs:
|
20
|
+
label: Text label for a web form field.
|
21
|
+
placeholder: Displays prompt text.
|
22
|
+
default: Value by default.
|
23
|
+
hide: Hide field from user.
|
24
|
+
disabled: Blocks access and modification of the element.
|
25
|
+
ignored: If true, the value of this field is not saved in the database.
|
26
|
+
hint: An alternative for the `placeholder` parameter.
|
27
|
+
warning: Warning information.
|
28
|
+
required: Required field.
|
29
|
+
readonly: Specifies that the field cannot be modified by the user.
|
30
|
+
unique: The unique value of a field in a collection.
|
31
|
+
max_number: Maximum allowed number.
|
32
|
+
min_number: Minimum allowed number.
|
33
|
+
step: Increment step for numeric fields.
|
34
|
+
input_type: Field type - `number` or `range`.
|
35
|
+
"""
|
18
36
|
|
19
37
|
def __init__( # noqa: D107
|
20
38
|
self,
|
21
39
|
label: str = "",
|
22
|
-
|
40
|
+
placeholder: str = "",
|
41
|
+
default: float | None = None,
|
23
42
|
hide: bool = False,
|
43
|
+
disabled: bool = False,
|
24
44
|
ignored: bool = False,
|
25
45
|
hint: str = "",
|
26
46
|
warning: list[str] | None = None,
|
27
|
-
default: float | None = None,
|
28
|
-
placeholder: str = "",
|
29
47
|
required: bool = False,
|
30
48
|
readonly: bool = False,
|
31
49
|
unique: bool = False,
|
ramifice/fields/general/field.py
CHANGED
@@ -2,10 +2,8 @@
|
|
2
2
|
|
3
3
|
__all__ = ("Field",)
|
4
4
|
|
5
|
-
from abc import ABCMeta
|
6
5
|
|
7
|
-
|
8
|
-
class Field(metaclass=ABCMeta):
|
6
|
+
class Field:
|
9
7
|
"""General parameters for all types fields of Model.
|
10
8
|
|
11
9
|
Args:
|
@@ -28,7 +26,7 @@ class Field(metaclass=ABCMeta):
|
|
28
26
|
ignored: bool = False,
|
29
27
|
hint: str = "",
|
30
28
|
warning: list[str] | None = None,
|
31
|
-
errors: list[str] = [],
|
29
|
+
errors: list[str] = [], # noqa: B006
|
32
30
|
field_type: str = "",
|
33
31
|
group: str = "",
|
34
32
|
) -> None:
|
ramifice/fields/id_field.py
CHANGED
@@ -17,23 +17,28 @@ logger = logging.getLogger(__name__)
|
|
17
17
|
class IDField(Field):
|
18
18
|
"""Field of Model for enter identifier of document.
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
placeholder
|
23
|
-
|
24
|
-
|
25
|
-
|
20
|
+
Agrs:
|
21
|
+
label: Text label for a web form field.
|
22
|
+
placeholder: Displays prompt text.
|
23
|
+
hide: Hide field from user.
|
24
|
+
disabled: Blocks access and modification of the element.
|
25
|
+
ignored: If true, the value of this field is not saved in the database.
|
26
|
+
hint: An alternative for the `placeholder` parameter.
|
27
|
+
warning: Warning information.
|
28
|
+
required: Required field.
|
29
|
+
readonly: Specifies that the field cannot be modified by the user.
|
30
|
+
unique: The unique value of a field in a collection.
|
26
31
|
"""
|
27
32
|
|
28
33
|
def __init__( # noqa: D107
|
29
34
|
self,
|
30
35
|
label: str = "",
|
31
|
-
|
36
|
+
placeholder: str = "",
|
32
37
|
hide: bool = False,
|
38
|
+
disabled: bool = False,
|
33
39
|
ignored: bool = False,
|
34
40
|
hint: str = "",
|
35
41
|
warning: list[str] | None = None,
|
36
|
-
placeholder: str = "",
|
37
42
|
required: bool = False,
|
38
43
|
readonly: bool = False,
|
39
44
|
unique: bool = False,
|
ramifice/fields/image_field.py
CHANGED
@@ -5,7 +5,7 @@ __all__ = ("ImageField",)
|
|
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,25 +23,40 @@ logger = logging.getLogger(__name__)
|
|
23
23
|
|
24
24
|
|
25
25
|
class ImageField(Field, FileGroup, JsonMixin):
|
26
|
-
"""Field of Model for upload image.
|
26
|
+
"""Field of Model for upload image.
|
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: "image/png,image/jpeg,image/webp".
|
41
|
+
thumbnails: Sizes of thumbnails - Example: {"lg": 1200, "md": 600, "sm": 300, "xs": 150 }.
|
42
|
+
"""
|
27
43
|
|
28
44
|
def __init__( # noqa: D107
|
29
45
|
self,
|
30
46
|
label: str = "",
|
31
|
-
|
47
|
+
placeholder: str = "",
|
48
|
+
default: str | None = None,
|
32
49
|
hide: bool = False,
|
50
|
+
disabled: bool = False,
|
33
51
|
ignored: bool = False,
|
34
52
|
hint: str = "",
|
35
53
|
warning: list[str] | None = None,
|
36
54
|
required: bool = False,
|
37
55
|
# The maximum size of the original image in bytes.
|
38
56
|
max_size: int = 2097152, # 2 MB = 2097152 Bytes (in binary)
|
39
|
-
default: str | None = None,
|
40
|
-
placeholder: str = "",
|
41
57
|
target_dir: str = "images",
|
42
58
|
accept: str = "image/png,image/jpeg,image/webp",
|
43
59
|
# Available 4 sizes from lg to xs or None.
|
44
|
-
# Example: {"lg": 1200, "md": 600, "sm": 300, "xs": 150 }
|
45
60
|
thumbnails: dict[str, int] | None = None,
|
46
61
|
) -> None:
|
47
62
|
if constants.DEBUG:
|
@@ -50,16 +65,12 @@ class ImageField(Field, FileGroup, JsonMixin):
|
|
50
65
|
if not isinstance(default, str):
|
51
66
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
52
67
|
if len(default) == 0:
|
53
|
-
raise AssertionError(
|
54
|
-
"The `default` parameter should not contain an empty string!"
|
55
|
-
)
|
68
|
+
raise AssertionError("The `default` parameter should not contain an empty string!")
|
56
69
|
if thumbnails is not None:
|
57
70
|
if not isinstance(thumbnails, dict):
|
58
71
|
raise AssertionError("Parameter `thumbnails` - Not а `dict` type!")
|
59
72
|
if len(thumbnails) == 0:
|
60
|
-
raise AssertionError(
|
61
|
-
"The `thumbnails` parameter should not contain an empty dictionary!"
|
62
|
-
)
|
73
|
+
raise AssertionError("The `thumbnails` parameter should not contain an empty dictionary!")
|
63
74
|
size_name_list = ["lg", "md", "sm", "xs"]
|
64
75
|
curr_size_thumb: int = 0
|
65
76
|
for size_name in thumbnails.keys():
|
@@ -130,7 +141,6 @@ class ImageField(Field, FileGroup, JsonMixin):
|
|
130
141
|
|
131
142
|
self.value: dict[str, str | int | bool] | None = None
|
132
143
|
# Available 4 sizes from lg to xs or None.
|
133
|
-
# Example: {"lg": 1200, "md": 600, "sm": 300, "xs": 150 }
|
134
144
|
self.thumbnails = thumbnails
|
135
145
|
|
136
146
|
async def from_base64(
|
@@ -163,7 +173,7 @@ class ImageField(Field, FileGroup, JsonMixin):
|
|
163
173
|
if item[0] == 40:
|
164
174
|
break
|
165
175
|
# Create the current date for the directory name.
|
166
|
-
date_str: str = str(
|
176
|
+
date_str: str = str(datetime.now().date()) # noqa: DTZ005
|
167
177
|
# Directory name for the original image and its thumbnails.
|
168
178
|
general_dir = uuid.uuid4()
|
169
179
|
# Create path to target directory with images.
|
@@ -222,7 +232,7 @@ class ImageField(Field, FileGroup, JsonMixin):
|
|
222
232
|
logger.error(msg)
|
223
233
|
raise FileHasNoExtensionError(msg)
|
224
234
|
# Create the current date for the directory name.
|
225
|
-
date_str: str = str(
|
235
|
+
date_str: str = str(datetime.now().date()) # noqa: DTZ005
|
226
236
|
# Directory name for the original image and its thumbnails.
|
227
237
|
general_dir = uuid.uuid4()
|
228
238
|
# Create path to target directory with images.
|
ramifice/fields/integer_field.py
CHANGED
@@ -14,18 +14,36 @@ logger = logging.getLogger(__name__)
|
|
14
14
|
|
15
15
|
|
16
16
|
class IntegerField(Field, NumberGroup, JsonMixin):
|
17
|
-
"""Field of Model for enter (int) number.
|
17
|
+
"""Field of Model for enter (int) number.
|
18
|
+
|
19
|
+
Agrs:
|
20
|
+
label: Text label for a web form field.
|
21
|
+
placeholder: Displays prompt text.
|
22
|
+
default: Value by default.
|
23
|
+
hide: Hide field from user.
|
24
|
+
disabled: Blocks access and modification of the element.
|
25
|
+
ignored: If true, the value of this field is not saved in the database.
|
26
|
+
hint: An alternative for the `placeholder` parameter.
|
27
|
+
warning: Warning information.
|
28
|
+
required: Required field.
|
29
|
+
readonly: Specifies that the field cannot be modified by the user.
|
30
|
+
unique: The unique value of a field in a collection.
|
31
|
+
max_number: Maximum allowed number.
|
32
|
+
min_number: Minimum allowed number.
|
33
|
+
step: Increment step for numeric fields.
|
34
|
+
input_type: Field type - `number` or `range`.
|
35
|
+
"""
|
18
36
|
|
19
37
|
def __init__( # noqa: D107
|
20
38
|
self,
|
21
39
|
label: str = "",
|
22
|
-
|
40
|
+
placeholder: str = "",
|
41
|
+
default: int | None = None,
|
23
42
|
hide: bool = False,
|
43
|
+
disabled: bool = False,
|
24
44
|
ignored: bool = False,
|
25
45
|
hint: str = "",
|
26
46
|
warning: list[str] | None = None,
|
27
|
-
default: int | None = None,
|
28
|
-
placeholder: str = "",
|
29
47
|
required: bool = False,
|
30
48
|
readonly: bool = False,
|
31
49
|
unique: bool = False,
|
ramifice/fields/ip_field.py
CHANGED
@@ -14,18 +14,32 @@ logger = logging.getLogger(__name__)
|
|
14
14
|
|
15
15
|
|
16
16
|
class IPField(Field, TextGroup, JsonMixin):
|
17
|
-
"""Field of Model for enter IP address.
|
17
|
+
"""Field of Model for enter IP address.
|
18
|
+
|
19
|
+
Agrs:
|
20
|
+
label: Text label for a web form field.
|
21
|
+
placeholder: Displays prompt text.
|
22
|
+
default: Value by default.
|
23
|
+
hide: Hide field from user.
|
24
|
+
disabled: Blocks access and modification of the element.
|
25
|
+
ignored: If true, the value of this field is not saved in the database.
|
26
|
+
hint: An alternative for the `placeholder` parameter.
|
27
|
+
warning: Warning information.
|
28
|
+
required: Required field.
|
29
|
+
readonly: Specifies that the field cannot be modified by the user.
|
30
|
+
unique: The unique value of a field in a collection.
|
31
|
+
"""
|
18
32
|
|
19
33
|
def __init__( # noqa: D107
|
20
34
|
self,
|
21
35
|
label: str = "",
|
22
|
-
|
36
|
+
placeholder: str = "",
|
37
|
+
default: str | None = None,
|
23
38
|
hide: bool = False,
|
39
|
+
disabled: bool = False,
|
24
40
|
ignored: bool = False,
|
25
41
|
hint: str = "",
|
26
42
|
warning: list[str] | None = None,
|
27
|
-
default: str | None = None,
|
28
|
-
placeholder: str = "",
|
29
43
|
required: bool = False,
|
30
44
|
readonly: bool = False,
|
31
45
|
unique: bool = False,
|
@@ -42,7 +56,7 @@ class IPField(Field, TextGroup, JsonMixin):
|
|
42
56
|
try:
|
43
57
|
ipaddress.ip_address(default)
|
44
58
|
except ValueError:
|
45
|
-
raise AssertionError("Parameter `default` - Invalid IP address!")
|
59
|
+
raise AssertionError("Parameter `default` - Invalid IP address!") # noqa: B904
|
46
60
|
if not isinstance(label, str):
|
47
61
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
48
62
|
if not isinstance(disabled, bool):
|
@@ -16,20 +16,29 @@ logger = logging.getLogger(__name__)
|
|
16
16
|
class PasswordField(Field):
|
17
17
|
r"""Field of Model for enter password.
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
Attention:
|
20
|
+
- Regular expression: ^[-._!"`'#%&,:;<>=@{}~$()*+/\\?[]^|a-zA-Z0-9]{8,256}$
|
21
|
+
- Valid characters: a-z A-Z 0-9 - . _ ! " ` ' # % & , : ; < > = @ { } ~ $ ( ) * + / \\ ? [ ] ^ |
|
22
|
+
- Number of characters: from 8 to 256.
|
23
|
+
|
24
|
+
Agrs:
|
25
|
+
label: Text label for a web form field.
|
26
|
+
placeholder: Displays prompt text.
|
27
|
+
hide: Hide field from user.
|
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.
|
23
32
|
"""
|
24
33
|
|
25
34
|
def __init__( # noqa: D107
|
26
35
|
self,
|
27
36
|
label: str = "",
|
37
|
+
placeholder: str = "",
|
28
38
|
hide: bool = False,
|
29
39
|
ignored: bool = False,
|
30
40
|
hint: str = "",
|
31
41
|
warning: list[str] | None = None,
|
32
|
-
placeholder: str = "",
|
33
42
|
required: bool = False,
|
34
43
|
) -> None:
|
35
44
|
if constants.DEBUG:
|
ramifice/fields/phone_field.py
CHANGED
@@ -17,19 +17,33 @@ logger = logging.getLogger(__name__)
|
|
17
17
|
class PhoneField(Field, TextGroup, JsonMixin):
|
18
18
|
"""Field of Model for enter phone number.
|
19
19
|
|
20
|
-
|
20
|
+
Attention:
|
21
|
+
By default is used validator `phonenumbers.is_valid_number()`.
|
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
|
+
unique: The unique value of a field in a collection.
|
21
35
|
"""
|
22
36
|
|
23
37
|
def __init__( # noqa: D107
|
24
38
|
self,
|
25
39
|
label: str = "",
|
26
|
-
|
40
|
+
placeholder: str = "",
|
41
|
+
default: str | None = None,
|
27
42
|
hide: bool = False,
|
43
|
+
disabled: bool = False,
|
28
44
|
ignored: bool = False,
|
29
45
|
hint: str = "",
|
30
46
|
warning: list[str] | None = None,
|
31
|
-
default: str | None = None,
|
32
|
-
placeholder: str = "",
|
33
47
|
required: bool = False,
|
34
48
|
readonly: bool = False,
|
35
49
|
unique: bool = False,
|
@@ -48,7 +62,7 @@ class PhoneField(Field, TextGroup, JsonMixin):
|
|
48
62
|
if not phonenumbers.is_valid_number(phone_default):
|
49
63
|
raise AssertionError()
|
50
64
|
except phonenumbers.phonenumberutil.NumberParseException:
|
51
|
-
raise AssertionError("Parameter `default` - Invalid Phone number!")
|
65
|
+
raise AssertionError("Parameter `default` - Invalid Phone number!") # noqa: B904
|
52
66
|
if not isinstance(label, str):
|
53
67
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
54
68
|
if not isinstance(disabled, bool):
|
ramifice/fields/slug_field.py
CHANGED
@@ -16,19 +16,30 @@ class SlugField(Field, TextGroup, JsonMixin):
|
|
16
16
|
"""Field of Model for automatic generation of string `slug`.
|
17
17
|
|
18
18
|
Convenient to use for Url addresses.
|
19
|
+
|
20
|
+
Agrs:
|
21
|
+
label: Text label for a web form field.
|
22
|
+
placeholder: Displays prompt text.
|
23
|
+
hide: Hide field from user.
|
24
|
+
disabled: Blocks access and modification of the element.
|
25
|
+
ignored: If true, the value of this field is not saved in the database.
|
26
|
+
hint: An alternative for the `placeholder` parameter.
|
27
|
+
warning: Warning information.
|
28
|
+
readonly: Specifies that the field cannot be modified by the user.
|
29
|
+
slug_sources: List of sources fields.
|
19
30
|
"""
|
20
31
|
|
21
32
|
def __init__( # noqa: D107
|
22
33
|
self,
|
23
34
|
label: str = "",
|
24
|
-
|
35
|
+
placeholder: str = "",
|
25
36
|
hide: bool = False,
|
37
|
+
disabled: bool = False,
|
26
38
|
ignored: bool = False,
|
27
39
|
hint: str = "",
|
28
40
|
warning: list[str] | None = None,
|
29
|
-
placeholder: str = "",
|
30
41
|
readonly: bool = False,
|
31
|
-
slug_sources: list[str] = ["_id"],
|
42
|
+
slug_sources: list[str] = ["_id"], # noqa: B006
|
32
43
|
) -> None:
|
33
44
|
if constants.DEBUG:
|
34
45
|
try:
|
ramifice/fields/text_field.py
CHANGED
@@ -12,19 +12,36 @@ logger = logging.getLogger(__name__)
|
|
12
12
|
|
13
13
|
|
14
14
|
class TextField(Field, JsonMixin):
|
15
|
-
"""Field of Model for enter text.
|
15
|
+
"""Field of Model for enter text.
|
16
|
+
|
17
|
+
Agrs:
|
18
|
+
label: Text label for a web form field.
|
19
|
+
placeholder: Displays prompt text.
|
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
|
+
textarea: Is it necessary to use the Textarea widget.
|
26
|
+
use_editor: Is it necessary to use the widget of the text editor.
|
27
|
+
required: Required field.
|
28
|
+
readonly: Specifies that the field cannot be modified by the user.
|
29
|
+
unique: The unique value of a field in a collection.
|
30
|
+
maxlength: The maximum line length.
|
31
|
+
multi_language: Is it need support for several languages.
|
32
|
+
"""
|
16
33
|
|
17
34
|
def __init__( # noqa: D107
|
18
35
|
self,
|
19
36
|
label: str = "",
|
20
|
-
|
37
|
+
placeholder: str = "",
|
21
38
|
hide: bool = False,
|
39
|
+
disabled: bool = False,
|
22
40
|
ignored: bool = False,
|
23
41
|
hint: str = "",
|
24
42
|
warning: list[str] | None = None,
|
25
43
|
textarea: bool = False,
|
26
44
|
use_editor: bool = False,
|
27
|
-
placeholder: str = "",
|
28
45
|
required: bool = False,
|
29
46
|
readonly: bool = False,
|
30
47
|
unique: bool = False,
|
ramifice/fields/url_field.py
CHANGED
@@ -16,30 +16,30 @@ logger = logging.getLogger(__name__)
|
|
16
16
|
class URLField(Field, TextGroup, JsonMixin):
|
17
17
|
"""Field of Model for enter URL address.
|
18
18
|
|
19
|
-
|
20
|
-
label
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
required
|
29
|
-
readonly
|
30
|
-
unique
|
19
|
+
Agrs:
|
20
|
+
label: Text label for a web form field.
|
21
|
+
placeholder: Displays prompt text.
|
22
|
+
default: Value by default.
|
23
|
+
hide: Hide field from user.
|
24
|
+
disabled: Blocks access and modification of the element.
|
25
|
+
ignored: If true, the value of this field is not saved in the database.
|
26
|
+
hint: An alternative for the `placeholder` parameter.
|
27
|
+
warning: Warning information.
|
28
|
+
required: Required field.
|
29
|
+
readonly: Specifies that the field cannot be modified by the user.
|
30
|
+
unique: The unique value of a field in a collection.
|
31
31
|
"""
|
32
32
|
|
33
33
|
def __init__( # noqa: D107
|
34
34
|
self,
|
35
35
|
label: str = "",
|
36
|
-
|
36
|
+
placeholder: str = "",
|
37
|
+
default: str | None = None,
|
37
38
|
hide: bool = False,
|
39
|
+
disabled: bool = False,
|
38
40
|
ignored: bool = False,
|
39
41
|
hint: str = "",
|
40
42
|
warning: list[str] | None = None,
|
41
|
-
default: str | None = None,
|
42
|
-
placeholder: str = "",
|
43
43
|
required: bool = False,
|
44
44
|
readonly: bool = False,
|
45
45
|
unique: bool = False,
|
ramifice/models/__init__.py
CHANGED
ramifice/models/decorator.py
CHANGED
@@ -61,13 +61,13 @@ def model(
|
|
61
61
|
if not exists(fixture_path):
|
62
62
|
msg = (
|
63
63
|
f"Model: `{cls.__module__}.{cls.__name__}` > "
|
64
|
-
+
|
64
|
+
+ "META param: `fixture_name` => "
|
65
65
|
+ f"Fixture the `{fixture_path}` not exists!"
|
66
66
|
)
|
67
67
|
logger.critical(msg)
|
68
68
|
raise PanicError(msg)
|
69
69
|
|
70
|
-
attrs =
|
70
|
+
attrs = dict(cls.__dict__)
|
71
71
|
attrs["__dict__"] = Model.__dict__["__dict__"]
|
72
72
|
metadata = {
|
73
73
|
"service_name": service_name,
|
ramifice/models/model.py
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
__all__ = ("Model",)
|
4
4
|
|
5
|
-
from abc import
|
6
|
-
from typing import Any
|
5
|
+
from abc import abstractmethod
|
6
|
+
from typing import Any, ClassVar
|
7
7
|
|
8
8
|
import orjson
|
9
9
|
from babel.dates import format_date, format_datetime
|
@@ -15,10 +15,10 @@ from ramifice.fields import DateTimeField, IDField
|
|
15
15
|
from ramifice.utils import translations
|
16
16
|
|
17
17
|
|
18
|
-
class Model
|
18
|
+
class Model:
|
19
19
|
"""Converting Python Class into Ramifice Model."""
|
20
20
|
|
21
|
-
META: dict[str, Any] = {}
|
21
|
+
META: ClassVar[dict[str, Any]] = {}
|
22
22
|
|
23
23
|
def __init__(self) -> None: # noqa: D107
|
24
24
|
_ = translations._
|
@@ -81,9 +81,7 @@ class Model(metaclass=ABCMeta):
|
|
81
81
|
if "Dyn" in f_type.field_type:
|
82
82
|
dyn_data = data_dynamic_fields[f_name]
|
83
83
|
if dyn_data is not None:
|
84
|
-
f_type.choices = [
|
85
|
-
[item["value"], item["title"][lang]] for item in dyn_data
|
86
|
-
]
|
84
|
+
f_type.choices = [[item["value"], item["title"][lang]] for item in dyn_data]
|
87
85
|
else:
|
88
86
|
# This is necessary for
|
89
87
|
# `paladins > refrash > RefrashMixin > refrash_from_db`.
|
ramifice/paladins/__init__.py
CHANGED
@@ -1,4 +1,19 @@
|
|
1
|
-
"""Paladins - Model instance methods.
|
1
|
+
"""Paladins - Model instance methods.
|
2
|
+
|
3
|
+
This module provides:
|
4
|
+
|
5
|
+
- `add_validation`: Contains an abstract method for additional validation of fields.
|
6
|
+
- `check`: Validation of Model data before saving to the database.
|
7
|
+
- `delete`: Delete document from database.
|
8
|
+
- `Hooks`: A set of abstract methods for creating hooks.
|
9
|
+
- `indexing`: Contains the method for indexing the model in the database.
|
10
|
+
- `password`: Verification, replacement and recoverang of password.
|
11
|
+
- `refrash_from_db`: Update Model instance from database.
|
12
|
+
- `save`: Create or update document in database.
|
13
|
+
- `Tools`: A set of auxiliary methods.
|
14
|
+
- `is_valid`: Validation of Model.
|
15
|
+
- `print_err`: Printing errors to console.
|
16
|
+
"""
|
2
17
|
|
3
18
|
__all__ = ("QPaladinsMixin",)
|
4
19
|
|
ramifice/paladins/add_valid.py
CHANGED
@@ -2,14 +2,15 @@
|
|
2
2
|
|
3
3
|
__all__ = ("AddValidMixin",)
|
4
4
|
|
5
|
-
from abc import
|
5
|
+
from abc import abstractmethod
|
6
6
|
|
7
7
|
from xloft import NamedTuple
|
8
8
|
|
9
9
|
|
10
|
-
class AddValidMixin
|
10
|
+
class AddValidMixin:
|
11
11
|
"""Contains an abstract method for additional validation of fields."""
|
12
12
|
|
13
|
+
@abstractmethod
|
13
14
|
async def add_validation(self) -> NamedTuple:
|
14
15
|
"""Additional validation of fields."""
|
15
16
|
return NamedTuple()
|