ramifice 0.3.28__py3-none-any.whl → 0.3.30__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/general.py +9 -9
- ramifice/commons/indexes.py +7 -7
- ramifice/commons/many.py +14 -14
- ramifice/commons/one.py +7 -7
- ramifice/commons/unit_manager.py +3 -5
- ramifice/fields/bool_field.py +2 -2
- ramifice/fields/choice_float_dyn_field.py +2 -2
- ramifice/fields/choice_float_field.py +2 -2
- ramifice/fields/choice_float_mult_dyn_field.py +2 -2
- ramifice/fields/choice_float_mult_field.py +2 -2
- ramifice/fields/choice_int_dyn_field.py +2 -2
- ramifice/fields/choice_int_field.py +2 -2
- ramifice/fields/choice_int_mult_dyn_field.py +2 -2
- ramifice/fields/choice_int_mult_field.py +2 -2
- ramifice/fields/choice_text_dyn_field.py +2 -2
- ramifice/fields/choice_text_field.py +2 -2
- ramifice/fields/choice_text_mult_dyn_field.py +2 -2
- ramifice/fields/choice_text_mult_field.py +2 -2
- ramifice/fields/color_field.py +3 -3
- ramifice/fields/date_field.py +2 -2
- ramifice/fields/date_time_field.py +2 -2
- ramifice/fields/email_field.py +2 -2
- ramifice/fields/file_field.py +2 -2
- ramifice/fields/float_field.py +2 -2
- ramifice/fields/id_field.py +2 -2
- ramifice/fields/image_field.py +2 -2
- ramifice/fields/integer_field.py +2 -2
- ramifice/fields/ip_field.py +2 -2
- ramifice/fields/password_field.py +2 -2
- ramifice/fields/phone_field.py +2 -2
- ramifice/fields/slug_field.py +2 -2
- ramifice/fields/text_field.py +2 -2
- ramifice/fields/url_field.py +2 -2
- ramifice/models/decorator.py +3 -3
- ramifice/models/model.py +1 -1
- ramifice/paladins/check.py +10 -10
- ramifice/paladins/delete.py +9 -9
- ramifice/paladins/groups/text_group.py +1 -1
- ramifice/paladins/password.py +9 -9
- ramifice/paladins/refrash.py +6 -6
- ramifice/paladins/save.py +15 -15
- ramifice/paladins/validation.py +4 -4
- ramifice/utils/{store.py → globals.py} +2 -4
- ramifice/utils/migration.py +16 -16
- ramifice/utils/tools.py +1 -1
- {ramifice-0.3.28.dist-info → ramifice-0.3.30.dist-info}/METADATA +1 -1
- ramifice-0.3.30.dist-info/RECORD +85 -0
- ramifice-0.3.28.dist-info/RECORD +0 -85
- {ramifice-0.3.28.dist-info → ramifice-0.3.30.dist-info}/WHEEL +0 -0
- {ramifice-0.3.28.dist-info → ramifice-0.3.30.dist-info}/licenses/LICENSE +0 -0
ramifice/commons/general.py
CHANGED
@@ -6,7 +6,7 @@ from pymongo.asynchronous.collection import AsyncCollection
|
|
6
6
|
from pymongo.asynchronous.command_cursor import AsyncCommandCursor
|
7
7
|
from pymongo.asynchronous.database import AsyncDatabase
|
8
8
|
|
9
|
-
from ..utils import
|
9
|
+
from ..utils import globals
|
10
10
|
|
11
11
|
|
12
12
|
class GeneralMixin:
|
@@ -20,7 +20,7 @@ class GeneralMixin:
|
|
20
20
|
) -> int:
|
21
21
|
"""Gets an estimate of the count of documents in a collection using collection metadata."""
|
22
22
|
# Get collection for current model.
|
23
|
-
collection: AsyncCollection =
|
23
|
+
collection: AsyncCollection = globals.MONGO_DATABASE[cls.META["collection_name"]]
|
24
24
|
#
|
25
25
|
return await collection.estimated_document_count(
|
26
26
|
comment=comment,
|
@@ -37,7 +37,7 @@ class GeneralMixin:
|
|
37
37
|
) -> int:
|
38
38
|
"""Gets an estimate of the count of documents in a collection using collection metadata."""
|
39
39
|
# Get collection for current model.
|
40
|
-
collection: AsyncCollection =
|
40
|
+
collection: AsyncCollection = globals.MONGO_DATABASE[cls.META["collection_name"]]
|
41
41
|
#
|
42
42
|
return await collection.count_documents(
|
43
43
|
filter=filter,
|
@@ -57,7 +57,7 @@ class GeneralMixin:
|
|
57
57
|
) -> AsyncCommandCursor:
|
58
58
|
"""Runs an aggregation framework pipeline."""
|
59
59
|
# Get collection for current model.
|
60
|
-
collection: AsyncCollection =
|
60
|
+
collection: AsyncCollection = globals.MONGO_DATABASE[cls.META["collection_name"]]
|
61
61
|
#
|
62
62
|
return await collection.aggregate(
|
63
63
|
pipeline=pipeline,
|
@@ -82,7 +82,7 @@ class GeneralMixin:
|
|
82
82
|
Returns an array of unique values for specified field of collection.
|
83
83
|
"""
|
84
84
|
# Get collection for current model.
|
85
|
-
collection: AsyncCollection =
|
85
|
+
collection: AsyncCollection = globals.MONGO_DATABASE[cls.META["collection_name"]]
|
86
86
|
#
|
87
87
|
return await collection.distinct(
|
88
88
|
key=key,
|
@@ -97,7 +97,7 @@ class GeneralMixin:
|
|
97
97
|
def collection_name(cls) -> str:
|
98
98
|
"""Get collection name."""
|
99
99
|
# Get collection for current model.
|
100
|
-
collection: AsyncCollection =
|
100
|
+
collection: AsyncCollection = globals.MONGO_DATABASE[cls.META["collection_name"]]
|
101
101
|
#
|
102
102
|
return collection.name
|
103
103
|
|
@@ -108,7 +108,7 @@ class GeneralMixin:
|
|
108
108
|
The full name is of the form database_name.collection_name.
|
109
109
|
"""
|
110
110
|
# Get collection for current model.
|
111
|
-
collection: AsyncCollection =
|
111
|
+
collection: AsyncCollection = globals.MONGO_DATABASE[cls.META["collection_name"]]
|
112
112
|
#
|
113
113
|
return collection.full_name
|
114
114
|
|
@@ -116,7 +116,7 @@ class GeneralMixin:
|
|
116
116
|
def database(cls) -> AsyncDatabase:
|
117
117
|
"""Get AsyncBatabase for the current Model."""
|
118
118
|
# Get collection for current model.
|
119
|
-
collection: AsyncCollection =
|
119
|
+
collection: AsyncCollection = globals.MONGO_DATABASE[cls.META["collection_name"]]
|
120
120
|
#
|
121
121
|
return collection.database
|
122
122
|
|
@@ -124,6 +124,6 @@ class GeneralMixin:
|
|
124
124
|
def collection(cls) -> AsyncCollection:
|
125
125
|
"""Get AsyncCollection for the current Model."""
|
126
126
|
# Get collection for current model.
|
127
|
-
collection: AsyncCollection =
|
127
|
+
collection: AsyncCollection = globals.MONGO_DATABASE[cls.META["collection_name"]]
|
128
128
|
#
|
129
129
|
return collection
|
ramifice/commons/indexes.py
CHANGED
@@ -4,7 +4,7 @@ from typing import Any
|
|
4
4
|
|
5
5
|
from pymongo.asynchronous.collection import AsyncCollection
|
6
6
|
|
7
|
-
from ..utils import
|
7
|
+
from ..utils import globals
|
8
8
|
|
9
9
|
|
10
10
|
class IndexMixin:
|
@@ -20,7 +20,7 @@ class IndexMixin:
|
|
20
20
|
) -> str:
|
21
21
|
"""Creates an index on this collection."""
|
22
22
|
# Get collection for current model.
|
23
|
-
collection: AsyncCollection =
|
23
|
+
collection: AsyncCollection = globals.MONGO_DATABASE[cls.META["collection_name"]]
|
24
24
|
# Create index.
|
25
25
|
result: str = await collection.create_index(
|
26
26
|
keys=keys,
|
@@ -40,7 +40,7 @@ class IndexMixin:
|
|
40
40
|
) -> None:
|
41
41
|
"""Drops the specified index on this collection."""
|
42
42
|
# Get collection for current model.
|
43
|
-
collection: AsyncCollection =
|
43
|
+
collection: AsyncCollection = globals.MONGO_DATABASE[cls.META["collection_name"]]
|
44
44
|
# Delete index.
|
45
45
|
await collection.drop_index(
|
46
46
|
index_or_name=index_or_name,
|
@@ -59,7 +59,7 @@ class IndexMixin:
|
|
59
59
|
) -> list[str]:
|
60
60
|
"""Create one or more indexes on this collection."""
|
61
61
|
# Get collection for current model.
|
62
|
-
collection: AsyncCollection =
|
62
|
+
collection: AsyncCollection = globals.MONGO_DATABASE[cls.META["collection_name"]]
|
63
63
|
# Create indexes.
|
64
64
|
result: list[str] = await collection.create_indexes(
|
65
65
|
indexes=indexes,
|
@@ -78,7 +78,7 @@ class IndexMixin:
|
|
78
78
|
) -> None:
|
79
79
|
"""Drops all indexes on this collection."""
|
80
80
|
# Get collection for current model.
|
81
|
-
collection: AsyncCollection =
|
81
|
+
collection: AsyncCollection = globals.MONGO_DATABASE[cls.META["collection_name"]]
|
82
82
|
# Delete indexes.
|
83
83
|
await collection.drop_indexes(session=session, comment=comment, **kwargs)
|
84
84
|
|
@@ -90,7 +90,7 @@ class IndexMixin:
|
|
90
90
|
) -> Any:
|
91
91
|
"""Get information on this collection’s indexes."""
|
92
92
|
# Get collection for current model.
|
93
|
-
collection: AsyncCollection =
|
93
|
+
collection: AsyncCollection = globals.MONGO_DATABASE[cls.META["collection_name"]]
|
94
94
|
# Get information.
|
95
95
|
result = await collection.index_information(session=session, comment=comment)
|
96
96
|
return result
|
@@ -103,7 +103,7 @@ class IndexMixin:
|
|
103
103
|
) -> Any:
|
104
104
|
"""Get a cursor over the index documents for this collection."""
|
105
105
|
# Get collection for current model.
|
106
|
-
collection: AsyncCollection =
|
106
|
+
collection: AsyncCollection = globals.MONGO_DATABASE[cls.META["collection_name"]]
|
107
107
|
# Get cursor.
|
108
108
|
cursor = await collection.list_indexes(session=session, comment=comment)
|
109
109
|
return cursor
|
ramifice/commons/many.py
CHANGED
@@ -4,10 +4,10 @@ import json
|
|
4
4
|
from typing import Any
|
5
5
|
|
6
6
|
from pymongo.asynchronous.collection import AsyncCollection
|
7
|
-
from pymongo.asynchronous.cursor import AsyncCursor, CursorType
|
7
|
+
from pymongo.asynchronous.cursor import AsyncCursor, CursorType
|
8
8
|
from pymongo.results import DeleteResult
|
9
9
|
|
10
|
-
from ..utils import
|
10
|
+
from ..utils import globals
|
11
11
|
from ..utils.errors import PanicError
|
12
12
|
from .tools import mongo_doc_to_raw_doc, password_to_none
|
13
13
|
|
@@ -42,14 +42,14 @@ class ManyMixin:
|
|
42
42
|
) -> list[dict[str, Any]]:
|
43
43
|
"""Find documents."""
|
44
44
|
# Get collection for current model.
|
45
|
-
collection: AsyncCollection =
|
45
|
+
collection: AsyncCollection = globals.MONGO_DATABASE[cls.META["collection_name"]]
|
46
46
|
# Get documents.
|
47
47
|
doc_list: list[dict[str, Any]] = []
|
48
48
|
cursor: AsyncCursor = collection.find(
|
49
49
|
filter=filter,
|
50
50
|
projection=projection,
|
51
51
|
skip=skip,
|
52
|
-
limit=limit or cls.META["db_query_docs_limit"],
|
52
|
+
limit=limit or cls.META["db_query_docs_limit"],
|
53
53
|
no_cursor_timeout=no_cursor_timeout,
|
54
54
|
cursor_type=cursor_type,
|
55
55
|
sort=sort,
|
@@ -68,7 +68,7 @@ class ManyMixin:
|
|
68
68
|
session=session,
|
69
69
|
allow_disk_use=allow_disk_use,
|
70
70
|
)
|
71
|
-
field_name_and_type = cls.META["field_name_and_type"]
|
71
|
+
field_name_and_type = cls.META["field_name_and_type"]
|
72
72
|
async for mongo_doc in cursor:
|
73
73
|
doc_list.append(password_to_none(field_name_and_type, mongo_doc))
|
74
74
|
return doc_list
|
@@ -107,14 +107,14 @@ class ManyMixin:
|
|
107
107
|
datetime to str
|
108
108
|
"""
|
109
109
|
# Get collection for current model.
|
110
|
-
collection: AsyncCollection =
|
110
|
+
collection: AsyncCollection = globals.MONGO_DATABASE[cls.META["collection_name"]]
|
111
111
|
# Get documents.
|
112
112
|
doc_list: list[dict[str, Any]] = []
|
113
113
|
cursor: AsyncCursor = collection.find(
|
114
114
|
filter=filter,
|
115
115
|
projection=projection,
|
116
116
|
skip=skip,
|
117
|
-
limit=limit or cls.META["db_query_docs_limit"],
|
117
|
+
limit=limit or cls.META["db_query_docs_limit"],
|
118
118
|
no_cursor_timeout=no_cursor_timeout,
|
119
119
|
cursor_type=cursor_type,
|
120
120
|
sort=sort,
|
@@ -133,7 +133,7 @@ class ManyMixin:
|
|
133
133
|
session=session,
|
134
134
|
allow_disk_use=allow_disk_use,
|
135
135
|
)
|
136
|
-
field_name_and_type = cls.META["field_name_and_type"]
|
136
|
+
field_name_and_type = cls.META["field_name_and_type"]
|
137
137
|
async for mongo_doc in cursor:
|
138
138
|
doc_list.append(mongo_doc_to_raw_doc(field_name_and_type, mongo_doc))
|
139
139
|
return doc_list
|
@@ -165,14 +165,14 @@ class ManyMixin:
|
|
165
165
|
) -> str | None:
|
166
166
|
"""Find documents and convert to a json string."""
|
167
167
|
# Get collection for current model.
|
168
|
-
collection: AsyncCollection =
|
168
|
+
collection: AsyncCollection = globals.MONGO_DATABASE[cls.META["collection_name"]]
|
169
169
|
# Get documents.
|
170
170
|
doc_list: list[dict[str, Any]] = []
|
171
171
|
cursor: AsyncCursor = collection.find(
|
172
172
|
filter=filter,
|
173
173
|
projection=projection,
|
174
174
|
skip=skip,
|
175
|
-
limit=limit or cls.META["db_query_docs_limit"],
|
175
|
+
limit=limit or cls.META["db_query_docs_limit"],
|
176
176
|
no_cursor_timeout=no_cursor_timeout,
|
177
177
|
cursor_type=cursor_type,
|
178
178
|
sort=sort,
|
@@ -191,7 +191,7 @@ class ManyMixin:
|
|
191
191
|
session=session,
|
192
192
|
allow_disk_use=allow_disk_use,
|
193
193
|
)
|
194
|
-
field_name_and_type = cls.META["field_name_and_type"]
|
194
|
+
field_name_and_type = cls.META["field_name_and_type"]
|
195
195
|
async for mongo_doc in cursor:
|
196
196
|
doc_list.append(mongo_doc_to_raw_doc(field_name_and_type, mongo_doc))
|
197
197
|
return json.dumps(doc_list) if len(doc_list) > 0 else None
|
@@ -208,15 +208,15 @@ class ManyMixin:
|
|
208
208
|
) -> DeleteResult:
|
209
209
|
"""Find documents matching with Model."""
|
210
210
|
# Raises a panic if the Model cannot be removed.
|
211
|
-
if not cls.META["is_delete_doc"]:
|
211
|
+
if not cls.META["is_delete_doc"]:
|
212
212
|
msg = (
|
213
|
-
f"Model: `{cls.META['full_model_name']}` > "
|
213
|
+
f"Model: `{cls.META['full_model_name']}` > "
|
214
214
|
+ "META param: `is_delete_doc` (False) => "
|
215
215
|
+ "Documents of this Model cannot be removed from the database!"
|
216
216
|
)
|
217
217
|
raise PanicError(msg)
|
218
218
|
# Get collection for current model.
|
219
|
-
collection: AsyncCollection =
|
219
|
+
collection: AsyncCollection = globals.MONGO_DATABASE[cls.META["collection_name"]]
|
220
220
|
# Delete documents.
|
221
221
|
result: DeleteResult = await collection.delete_many(
|
222
222
|
filter=filter,
|
ramifice/commons/one.py
CHANGED
@@ -5,7 +5,7 @@ from typing import Any
|
|
5
5
|
from pymongo.asynchronous.collection import AsyncCollection
|
6
6
|
from pymongo.results import DeleteResult
|
7
7
|
|
8
|
-
from ..utils import
|
8
|
+
from ..utils import globals
|
9
9
|
from ..utils.errors import PanicError
|
10
10
|
from .tools import from_mongo_doc, mongo_doc_to_raw_doc, password_to_none
|
11
11
|
|
@@ -22,7 +22,7 @@ class OneMixin:
|
|
22
22
|
) -> dict[str, Any] | None:
|
23
23
|
"""Find a single document."""
|
24
24
|
# Get collection for current model.
|
25
|
-
collection: AsyncCollection =
|
25
|
+
collection: AsyncCollection = globals.MONGO_DATABASE[cls.META["collection_name"]]
|
26
26
|
# Get document.
|
27
27
|
mongo_doc = await collection.find_one(filter, *args, **kwargs)
|
28
28
|
if mongo_doc is not None:
|
@@ -41,7 +41,7 @@ class OneMixin:
|
|
41
41
|
) -> dict[str, Any] | None:
|
42
42
|
"""Find a single document and converting to raw document."""
|
43
43
|
# Get collection for current model.
|
44
|
-
collection: AsyncCollection =
|
44
|
+
collection: AsyncCollection = globals.MONGO_DATABASE[cls.META["collection_name"]]
|
45
45
|
# Get document.
|
46
46
|
raw_doc = None
|
47
47
|
mongo_doc = await collection.find_one(filter, *args, **kwargs)
|
@@ -61,7 +61,7 @@ class OneMixin:
|
|
61
61
|
) -> Any | None:
|
62
62
|
"""Find a single document and convert it to a Model instance."""
|
63
63
|
# Get collection for current model.
|
64
|
-
collection: AsyncCollection =
|
64
|
+
collection: AsyncCollection = globals.MONGO_DATABASE[cls.META["collection_name"]]
|
65
65
|
# Get document.
|
66
66
|
inst_model = None
|
67
67
|
mongo_doc = await collection.find_one(filter, *args, **kwargs)
|
@@ -79,7 +79,7 @@ class OneMixin:
|
|
79
79
|
) -> str | None:
|
80
80
|
"""Find a single document and convert it to a JSON string."""
|
81
81
|
# Get collection for current model.
|
82
|
-
collection: AsyncCollection =
|
82
|
+
collection: AsyncCollection = globals.MONGO_DATABASE[cls.META["collection_name"]]
|
83
83
|
# Get document.
|
84
84
|
json_str: str | None = None
|
85
85
|
mongo_doc = await collection.find_one(filter, *args, **kwargs)
|
@@ -109,7 +109,7 @@ class OneMixin:
|
|
109
109
|
)
|
110
110
|
raise PanicError(msg)
|
111
111
|
# Get collection for current model.
|
112
|
-
collection: AsyncCollection =
|
112
|
+
collection: AsyncCollection = globals.MONGO_DATABASE[cls.META["collection_name"]]
|
113
113
|
# Get document.
|
114
114
|
result: DeleteResult = await collection.delete_one(
|
115
115
|
filter=filter,
|
@@ -143,7 +143,7 @@ class OneMixin:
|
|
143
143
|
)
|
144
144
|
raise PanicError(msg)
|
145
145
|
# Get collection for current model.
|
146
|
-
collection: AsyncCollection =
|
146
|
+
collection: AsyncCollection = globals.MONGO_DATABASE[cls.META["collection_name"]]
|
147
147
|
# Get document.
|
148
148
|
mongo_doc: dict[str, Any] | None = await collection.find_one_and_delete(
|
149
149
|
filter=filter,
|
ramifice/commons/unit_manager.py
CHANGED
@@ -7,7 +7,7 @@ from typing import Any
|
|
7
7
|
|
8
8
|
from pymongo.asynchronous.collection import AsyncCollection
|
9
9
|
|
10
|
-
from ..utils import
|
10
|
+
from ..utils import globals
|
11
11
|
from ..utils.errors import PanicError
|
12
12
|
from ..utils.unit import Unit
|
13
13
|
|
@@ -26,9 +26,7 @@ class UnitMixin:
|
|
26
26
|
"""
|
27
27
|
# Get access to super collection.
|
28
28
|
# (Contains Model state and dynamic field data.)
|
29
|
-
super_collection: AsyncCollection =
|
30
|
-
store.SUPER_COLLECTION_NAME
|
31
|
-
]
|
29
|
+
super_collection: AsyncCollection = globals.MONGO_DATABASE[globals.SUPER_COLLECTION_NAME]
|
32
30
|
# Get Model state.
|
33
31
|
model_state: dict[str, Any] | None = await super_collection.find_one(
|
34
32
|
filter={"collection_name": cls.META["collection_name"]}
|
@@ -89,7 +87,7 @@ class UnitMixin:
|
|
89
87
|
if unit.is_delete:
|
90
88
|
unit_field: str = unit.field
|
91
89
|
unit_value: float | int | str = unit.value
|
92
|
-
collection: AsyncCollection =
|
90
|
+
collection: AsyncCollection = globals.MONGO_DATABASE[cls.META["collection_name"]]
|
93
91
|
async for mongo_doc in collection.find():
|
94
92
|
field_value = mongo_doc[unit_field]
|
95
93
|
if field_value is not None:
|
ramifice/fields/bool_field.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"""Field of Model for enter boolean value."""
|
2
2
|
|
3
|
-
from ..utils import
|
3
|
+
from ..utils import globals
|
4
4
|
from ..utils.mixins.json_converter import JsonMixin
|
5
5
|
from .general.field import Field
|
6
6
|
|
@@ -18,7 +18,7 @@ class BooleanField(Field, JsonMixin):
|
|
18
18
|
warning: list[str] | None = None,
|
19
19
|
default: bool = False,
|
20
20
|
):
|
21
|
-
if
|
21
|
+
if globals.DEBUG:
|
22
22
|
if default is not None and not isinstance(default, bool):
|
23
23
|
raise AssertionError("Parameter `default` - Not а `bool` type!")
|
24
24
|
if not isinstance(label, str):
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Type of selective float field with dynamic addition of elements.
|
4
4
|
"""
|
5
5
|
|
6
|
-
from ..utils import
|
6
|
+
from ..utils import globals
|
7
7
|
from ..utils.mixins.json_converter import JsonMixin
|
8
8
|
from .general.choice_group import ChoiceGroup
|
9
9
|
from .general.field import Field
|
@@ -28,7 +28,7 @@ class ChoiceFloatDynField(Field, ChoiceGroup, JsonMixin):
|
|
28
28
|
required: bool = False,
|
29
29
|
readonly: bool = False,
|
30
30
|
):
|
31
|
-
if
|
31
|
+
if globals.DEBUG:
|
32
32
|
if not isinstance(label, str):
|
33
33
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
34
34
|
if not isinstance(disabled, bool):
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Type of selective float field with static of elements.
|
4
4
|
"""
|
5
5
|
|
6
|
-
from ..utils import
|
6
|
+
from ..utils import globals
|
7
7
|
from ..utils.mixins.json_converter import JsonMixin
|
8
8
|
from .general.choice_group import ChoiceGroup
|
9
9
|
from .general.field import Field
|
@@ -51,7 +51,7 @@ class ChoiceFloatField(Field, ChoiceGroup, JsonMixin):
|
|
51
51
|
self.default = default
|
52
52
|
self.choices = choices
|
53
53
|
|
54
|
-
if
|
54
|
+
if globals.DEBUG:
|
55
55
|
if choices is not None and not isinstance(choices, dict):
|
56
56
|
raise AssertionError("Parameter `choices` - Not а `dict` type!")
|
57
57
|
if default is not None and not isinstance(default, float):
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Type of selective float field with dynamic addition of elements.
|
4
4
|
"""
|
5
5
|
|
6
|
-
from ..utils import
|
6
|
+
from ..utils import globals
|
7
7
|
from ..utils.mixins.json_converter import JsonMixin
|
8
8
|
from .general.choice_group import ChoiceGroup
|
9
9
|
from .general.field import Field
|
@@ -27,7 +27,7 @@ class ChoiceFloatMultDynField(Field, ChoiceGroup, JsonMixin):
|
|
27
27
|
required: bool = False,
|
28
28
|
readonly: bool = False,
|
29
29
|
):
|
30
|
-
if
|
30
|
+
if globals.DEBUG:
|
31
31
|
if not isinstance(label, str):
|
32
32
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
33
33
|
if not isinstance(disabled, bool):
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Type of selective float field with static of elements.
|
4
4
|
"""
|
5
5
|
|
6
|
-
from ..utils import
|
6
|
+
from ..utils import globals
|
7
7
|
from ..utils.mixins.json_converter import JsonMixin
|
8
8
|
from .general.choice_group import ChoiceGroup
|
9
9
|
from .general.field import Field
|
@@ -52,7 +52,7 @@ class ChoiceFloatMultField(Field, ChoiceGroup, JsonMixin):
|
|
52
52
|
self.default = default
|
53
53
|
self.choices = choices
|
54
54
|
|
55
|
-
if
|
55
|
+
if globals.DEBUG:
|
56
56
|
if choices is not None:
|
57
57
|
if not isinstance(choices, dict):
|
58
58
|
raise AssertionError("Parameter `choices` - Not а `dict` type!")
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Type of selective integer field with dynamic addition of elements.
|
4
4
|
"""
|
5
5
|
|
6
|
-
from ..utils import
|
6
|
+
from ..utils import globals
|
7
7
|
from ..utils.mixins.json_converter import JsonMixin
|
8
8
|
from .general.choice_group import ChoiceGroup
|
9
9
|
from .general.field import Field
|
@@ -28,7 +28,7 @@ class ChoiceIntDynField(Field, ChoiceGroup, JsonMixin):
|
|
28
28
|
required: bool = False,
|
29
29
|
readonly: bool = False,
|
30
30
|
):
|
31
|
-
if
|
31
|
+
if globals.DEBUG:
|
32
32
|
if not isinstance(label, str):
|
33
33
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
34
34
|
if not isinstance(disabled, bool):
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Type of selective integer field with static of elements.
|
4
4
|
"""
|
5
5
|
|
6
|
-
from ..utils import
|
6
|
+
from ..utils import globals
|
7
7
|
from ..utils.mixins.json_converter import JsonMixin
|
8
8
|
from .general.choice_group import ChoiceGroup
|
9
9
|
from .general.field import Field
|
@@ -51,7 +51,7 @@ class ChoiceIntField(Field, ChoiceGroup, JsonMixin):
|
|
51
51
|
self.default = default
|
52
52
|
self.choices = choices
|
53
53
|
|
54
|
-
if
|
54
|
+
if globals.DEBUG:
|
55
55
|
if choices is not None and not isinstance(choices, dict):
|
56
56
|
raise AssertionError("Parameter `choices` - Not а `dict` type!")
|
57
57
|
if default is not None and not isinstance(default, int):
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Type of selective integer field with dynamic addition of elements.
|
4
4
|
"""
|
5
5
|
|
6
|
-
from ..utils import
|
6
|
+
from ..utils import globals
|
7
7
|
from ..utils.mixins.json_converter import JsonMixin
|
8
8
|
from .general.choice_group import ChoiceGroup
|
9
9
|
from .general.field import Field
|
@@ -27,7 +27,7 @@ class ChoiceIntMultDynField(Field, ChoiceGroup, JsonMixin):
|
|
27
27
|
required: bool = False,
|
28
28
|
readonly: bool = False,
|
29
29
|
):
|
30
|
-
if
|
30
|
+
if globals.DEBUG:
|
31
31
|
if not isinstance(label, str):
|
32
32
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
33
33
|
if not isinstance(disabled, bool):
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Type of selective integer field with static of elements.
|
4
4
|
"""
|
5
5
|
|
6
|
-
from ..utils import
|
6
|
+
from ..utils import globals
|
7
7
|
from ..utils.mixins.json_converter import JsonMixin
|
8
8
|
from .general.choice_group import ChoiceGroup
|
9
9
|
from .general.field import Field
|
@@ -52,7 +52,7 @@ class ChoiceIntMultField(Field, ChoiceGroup, JsonMixin):
|
|
52
52
|
self.default = default
|
53
53
|
self.choices = choices
|
54
54
|
|
55
|
-
if
|
55
|
+
if globals.DEBUG:
|
56
56
|
if choices is not None:
|
57
57
|
if not isinstance(choices, dict):
|
58
58
|
raise AssertionError("Parameter `choices` - Not а `dict` type!")
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Type of selective text field with dynamic addition of elements.
|
4
4
|
"""
|
5
5
|
|
6
|
-
from ..utils import
|
6
|
+
from ..utils import globals
|
7
7
|
from ..utils.mixins.json_converter import JsonMixin
|
8
8
|
from .general.choice_group import ChoiceGroup
|
9
9
|
from .general.field import Field
|
@@ -28,7 +28,7 @@ class ChoiceTextDynField(Field, ChoiceGroup, JsonMixin):
|
|
28
28
|
required: bool = False,
|
29
29
|
readonly: bool = False,
|
30
30
|
):
|
31
|
-
if
|
31
|
+
if globals.DEBUG:
|
32
32
|
if not isinstance(label, str):
|
33
33
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
34
34
|
if not isinstance(disabled, bool):
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Type of selective text field with static of elements.
|
4
4
|
"""
|
5
5
|
|
6
|
-
from ..utils import
|
6
|
+
from ..utils import globals
|
7
7
|
from ..utils.mixins.json_converter import JsonMixin
|
8
8
|
from .general.choice_group import ChoiceGroup
|
9
9
|
from .general.field import Field
|
@@ -51,7 +51,7 @@ class ChoiceTextField(Field, ChoiceGroup, JsonMixin):
|
|
51
51
|
self.default = default
|
52
52
|
self.choices = choices
|
53
53
|
|
54
|
-
if
|
54
|
+
if globals.DEBUG:
|
55
55
|
if choices is not None and not isinstance(choices, dict):
|
56
56
|
raise AssertionError("Parameter `choices` - Not а `dict` type!")
|
57
57
|
if default is not None:
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Type of selective text field with dynamic addition of elements.
|
4
4
|
"""
|
5
5
|
|
6
|
-
from ..utils import
|
6
|
+
from ..utils import globals
|
7
7
|
from ..utils.mixins.json_converter import JsonMixin
|
8
8
|
from .general.choice_group import ChoiceGroup
|
9
9
|
from .general.field import Field
|
@@ -27,7 +27,7 @@ class ChoiceTextMultDynField(Field, ChoiceGroup, JsonMixin):
|
|
27
27
|
required: bool = False,
|
28
28
|
readonly: bool = False,
|
29
29
|
):
|
30
|
-
if
|
30
|
+
if globals.DEBUG:
|
31
31
|
if not isinstance(label, str):
|
32
32
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
33
33
|
if not isinstance(disabled, bool):
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Type of selective text field with static of elements.
|
4
4
|
"""
|
5
5
|
|
6
|
-
from ..utils import
|
6
|
+
from ..utils import globals
|
7
7
|
from ..utils.mixins.json_converter import JsonMixin
|
8
8
|
from .general.choice_group import ChoiceGroup
|
9
9
|
from .general.field import Field
|
@@ -52,7 +52,7 @@ class ChoiceTextMultField(Field, ChoiceGroup, JsonMixin):
|
|
52
52
|
self.default = default
|
53
53
|
self.choices = choices
|
54
54
|
|
55
|
-
if
|
55
|
+
if globals.DEBUG:
|
56
56
|
if choices is not None:
|
57
57
|
if not isinstance(choices, dict):
|
58
58
|
raise AssertionError("Parameter `choices` - Not а `dict` type!")
|
ramifice/fields/color_field.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"""Field of Model for enter color code."""
|
2
2
|
|
3
|
-
from ..utils import
|
3
|
+
from ..utils import globals
|
4
4
|
from ..utils.mixins.json_converter import JsonMixin
|
5
5
|
from .general.field import Field
|
6
6
|
from .general.text_group import TextGroup
|
@@ -31,7 +31,7 @@ class ColorField(Field, TextGroup, JsonMixin):
|
|
31
31
|
readonly: bool = False,
|
32
32
|
unique: bool = False,
|
33
33
|
):
|
34
|
-
if
|
34
|
+
if globals.DEBUG:
|
35
35
|
if default is not None:
|
36
36
|
if not isinstance(default, str):
|
37
37
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
@@ -39,7 +39,7 @@ class ColorField(Field, TextGroup, JsonMixin):
|
|
39
39
|
raise AssertionError(
|
40
40
|
"The `default` parameter should not contain an empty string!"
|
41
41
|
)
|
42
|
-
if
|
42
|
+
if globals.REGEX["color_code"].match(default) is None:
|
43
43
|
raise AssertionError("Parameter `default` - Not а color code!")
|
44
44
|
if not isinstance(label, str):
|
45
45
|
raise AssertionError("Parameter `default` - Not а `str` type!")
|
ramifice/fields/date_field.py
CHANGED
@@ -7,7 +7,7 @@ from typing import Any
|
|
7
7
|
from babel.dates import format_date
|
8
8
|
from dateutil.parser import parse
|
9
9
|
|
10
|
-
from ..utils import
|
10
|
+
from ..utils import globals, translations
|
11
11
|
from .general.date_group import DateGroup
|
12
12
|
from .general.field import Field
|
13
13
|
|
@@ -30,7 +30,7 @@ class DateField(Field, DateGroup):
|
|
30
30
|
max_date: datetime | None = None,
|
31
31
|
min_date: datetime | None = None,
|
32
32
|
):
|
33
|
-
if
|
33
|
+
if globals.DEBUG:
|
34
34
|
if max_date is not None:
|
35
35
|
if not isinstance(max_date, datetime):
|
36
36
|
raise AssertionError("Parameter `max_date` - Not а `str` type!")
|
@@ -7,7 +7,7 @@ from typing import Any
|
|
7
7
|
from babel.dates import format_datetime
|
8
8
|
from dateutil.parser import parse
|
9
9
|
|
10
|
-
from ..utils import
|
10
|
+
from ..utils import globals, translations
|
11
11
|
from .general.date_group import DateGroup
|
12
12
|
from .general.field import Field
|
13
13
|
|
@@ -30,7 +30,7 @@ class DateTimeField(Field, DateGroup):
|
|
30
30
|
max_date: datetime | None = None,
|
31
31
|
min_date: datetime | None = None,
|
32
32
|
):
|
33
|
-
if
|
33
|
+
if globals.DEBUG:
|
34
34
|
if max_date is not None:
|
35
35
|
if not isinstance(max_date, datetime):
|
36
36
|
raise AssertionError("Parameter `max_date` - Not а `str` type!")
|