ramifice 0.8.22__py3-none-any.whl → 0.8.26__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 +16 -6
- ramifice/fields/choice_float_dyn_field.py +16 -6
- ramifice/fields/choice_float_field.py +20 -8
- ramifice/fields/choice_float_mult_dyn_field.py +16 -6
- ramifice/fields/choice_float_mult_field.py +20 -8
- ramifice/fields/choice_int_dyn_field.py +16 -6
- ramifice/fields/choice_int_field.py +20 -8
- ramifice/fields/choice_int_mult_dyn_field.py +16 -6
- ramifice/fields/choice_int_mult_field.py +20 -8
- ramifice/fields/choice_text_dyn_field.py +16 -6
- ramifice/fields/choice_text_field.py +20 -8
- ramifice/fields/choice_text_mult_dyn_field.py +16 -6
- ramifice/fields/choice_text_mult_field.py +20 -8
- ramifice/fields/color_field.py +24 -11
- ramifice/fields/date_field.py +25 -10
- ramifice/fields/date_time_field.py +25 -10
- ramifice/fields/email_field.py +21 -7
- ramifice/fields/file_field.py +25 -10
- ramifice/fields/float_field.py +25 -7
- 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 +20 -15
- ramifice/fields/image_field.py +25 -9
- ramifice/fields/integer_field.py +25 -7
- ramifice/fields/ip_field.py +21 -7
- ramifice/fields/password_field.py +21 -12
- ramifice/fields/phone_field.py +22 -8
- ramifice/fields/slug_field.py +17 -6
- ramifice/fields/text_field.py +24 -7
- ramifice/fields/url_field.py +19 -19
- ramifice/models/__init__.py +7 -1
- ramifice/models/decorator.py +3 -3
- ramifice/models/model.py +16 -16
- ramifice/paladins/__init__.py +17 -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.22.dist-info → ramifice-0.8.26.dist-info}/METADATA +4 -4
- ramifice-0.8.26.dist-info/RECORD +83 -0
- ramifice/utils/mixins/__init__.py +0 -5
- ramifice-0.8.22.dist-info/RECORD +0 -84
- {ramifice-0.8.22.dist-info → ramifice-0.8.26.dist-info}/WHEEL +0 -0
- {ramifice-0.8.22.dist-info → ramifice-0.8.26.dist-info}/licenses/LICENSE +0 -0
ramifice/__init__.py
CHANGED
@@ -12,7 +12,14 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
"""ORM-pseudo-like API MongoDB for Python language.
|
15
|
+
"""ORM-pseudo-like API MongoDB for Python language.
|
16
|
+
|
17
|
+
Ramifice is built around <a href="https://pypi.org/project/pymongo/" alt="PyMongo">PyMongo</a>.
|
18
|
+
|
19
|
+
For simulate relationship Many-to-One and Many-to-Many,
|
20
|
+
a simplified alternative (Types of selective fields with dynamic addition of elements) is used.
|
21
|
+
The project is more concentrated for web development or for applications with a graphic interface.
|
22
|
+
"""
|
16
23
|
|
17
24
|
__all__ = (
|
18
25
|
"NamedTuple",
|
ramifice/commons/__init__.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Commons - Model class methods."""
|
2
2
|
|
3
3
|
__all__ = ("QCommonsMixin",)
|
4
4
|
|
@@ -16,7 +16,7 @@ class QCommonsMixin(
|
|
16
16
|
IndexMixin,
|
17
17
|
UnitMixin,
|
18
18
|
):
|
19
|
-
"""
|
19
|
+
"""Commons - Model class methods."""
|
20
20
|
|
21
21
|
def __init__(self) -> None: # noqa: D107
|
22
22
|
super().__init__()
|
ramifice/commons/general.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""General purpose query methods."""
|
2
2
|
|
3
3
|
__all__ = ("GeneralMixin",)
|
4
4
|
|
@@ -13,14 +13,14 @@ from ramifice.utils import constants, translations
|
|
13
13
|
|
14
14
|
|
15
15
|
class GeneralMixin:
|
16
|
-
"""
|
16
|
+
"""General purpose query methods."""
|
17
17
|
|
18
18
|
@classmethod
|
19
19
|
def from_mongo_doc(
|
20
20
|
cls,
|
21
21
|
mongo_doc: dict[str, Any],
|
22
22
|
) -> Any:
|
23
|
-
"""
|
23
|
+
"""Create object instance from Mongo document."""
|
24
24
|
obj: Any = cls()
|
25
25
|
lang: str = translations.CURRENT_LOCALE
|
26
26
|
for name, data in mongo_doc.items():
|
@@ -41,7 +41,7 @@ class GeneralMixin:
|
|
41
41
|
comment: Any | None = None,
|
42
42
|
**kwargs,
|
43
43
|
) -> int:
|
44
|
-
"""
|
44
|
+
"""Gets an estimate of the count of documents in a collection using collection metadata."""
|
45
45
|
# Get collection for current model.
|
46
46
|
collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
|
47
47
|
#
|
@@ -58,7 +58,7 @@ class GeneralMixin:
|
|
58
58
|
comment: Any | None = None,
|
59
59
|
**kwargs,
|
60
60
|
) -> int:
|
61
|
-
"""
|
61
|
+
"""Gets an estimate of the count of documents in a collection using collection metadata."""
|
62
62
|
# Get collection for current model.
|
63
63
|
collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
|
64
64
|
# Correcting filter.
|
@@ -81,7 +81,7 @@ class GeneralMixin:
|
|
81
81
|
comment: Any | None = None,
|
82
82
|
**kwargs,
|
83
83
|
) -> AsyncCommandCursor:
|
84
|
-
"""
|
84
|
+
"""Runs an aggregation framework pipeline."""
|
85
85
|
# Get collection for current model.
|
86
86
|
collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
|
87
87
|
# Correcting filter.
|
@@ -106,7 +106,7 @@ class GeneralMixin:
|
|
106
106
|
hint: Any | None = None,
|
107
107
|
**kwargs,
|
108
108
|
) -> list[Any]:
|
109
|
-
"""
|
109
|
+
"""Finds the distinct values for a specified field across a single collection.
|
110
110
|
|
111
111
|
Returns an array of unique values for specified field of collection.
|
112
112
|
"""
|
@@ -127,7 +127,7 @@ class GeneralMixin:
|
|
127
127
|
|
128
128
|
@classmethod
|
129
129
|
def collection_name(cls) -> str:
|
130
|
-
"""
|
130
|
+
"""Get collection name."""
|
131
131
|
# Get collection for current model.
|
132
132
|
collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
|
133
133
|
#
|
@@ -135,7 +135,7 @@ class GeneralMixin:
|
|
135
135
|
|
136
136
|
@classmethod
|
137
137
|
def collection_full_name(cls) -> str:
|
138
|
-
"""
|
138
|
+
"""The full name of this AsyncCollection.
|
139
139
|
|
140
140
|
The full name is of the form database_name.collection_name.
|
141
141
|
"""
|
@@ -146,7 +146,7 @@ class GeneralMixin:
|
|
146
146
|
|
147
147
|
@classmethod
|
148
148
|
def database(cls) -> AsyncDatabase:
|
149
|
-
"""
|
149
|
+
"""Get AsyncBatabase for the current Model."""
|
150
150
|
# Get collection for current model.
|
151
151
|
collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
|
152
152
|
#
|
@@ -154,7 +154,7 @@ class GeneralMixin:
|
|
154
154
|
|
155
155
|
@classmethod
|
156
156
|
def collection(cls) -> AsyncCollection:
|
157
|
-
"""
|
157
|
+
"""Get AsyncCollection for the current Model."""
|
158
158
|
# Get collection for current model.
|
159
159
|
collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
|
160
160
|
#
|
ramifice/commons/indexes.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Indexation documents of collection."""
|
2
2
|
|
3
3
|
__all__ = ("IndexMixin",)
|
4
4
|
|
@@ -10,7 +10,7 @@ from ramifice.utils import constants
|
|
10
10
|
|
11
11
|
|
12
12
|
class IndexMixin:
|
13
|
-
"""
|
13
|
+
"""Indexation documents of collection."""
|
14
14
|
|
15
15
|
@classmethod
|
16
16
|
async def create_index( # type: ignore[no-untyped-def]
|
@@ -20,7 +20,7 @@ class IndexMixin:
|
|
20
20
|
comment: Any | None = None,
|
21
21
|
**kwargs,
|
22
22
|
) -> str:
|
23
|
-
"""
|
23
|
+
"""Creates an index on this collection."""
|
24
24
|
# Get collection for current model.
|
25
25
|
collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
|
26
26
|
# Create index.
|
@@ -40,7 +40,7 @@ class IndexMixin:
|
|
40
40
|
comment: Any | None = None,
|
41
41
|
**kwargs,
|
42
42
|
) -> None:
|
43
|
-
"""
|
43
|
+
"""Drops the specified index on this collection."""
|
44
44
|
# Get collection for current model.
|
45
45
|
collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
|
46
46
|
# Delete index.
|
@@ -59,7 +59,7 @@ class IndexMixin:
|
|
59
59
|
comment: Any | None = None,
|
60
60
|
**kwargs,
|
61
61
|
) -> list[str]:
|
62
|
-
"""
|
62
|
+
"""Create one or more indexes on this collection."""
|
63
63
|
# Get collection for current model.
|
64
64
|
collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
|
65
65
|
# Create indexes.
|
@@ -78,7 +78,7 @@ class IndexMixin:
|
|
78
78
|
comment: Any | None = None,
|
79
79
|
**kwargs,
|
80
80
|
) -> None:
|
81
|
-
"""
|
81
|
+
"""Drops all indexes on this collection."""
|
82
82
|
# Get collection for current model.
|
83
83
|
collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
|
84
84
|
# Delete indexes.
|
@@ -90,7 +90,7 @@ class IndexMixin:
|
|
90
90
|
session: Any | None = None,
|
91
91
|
comment: Any | None = None,
|
92
92
|
) -> Any:
|
93
|
-
"""
|
93
|
+
"""Get information on this collection’s indexes."""
|
94
94
|
# Get collection for current model.
|
95
95
|
collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
|
96
96
|
# Get information.
|
@@ -103,7 +103,7 @@ class IndexMixin:
|
|
103
103
|
session: Any | None = None,
|
104
104
|
comment: Any | None = None,
|
105
105
|
) -> Any:
|
106
|
-
"""
|
106
|
+
"""Get a cursor over the index documents for this collection."""
|
107
107
|
# Get collection for current model.
|
108
108
|
collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
|
109
109
|
# Get cursor.
|
ramifice/commons/many.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Queries like `find many`."""
|
2
2
|
|
3
3
|
__all__ = ("ManyMixin",)
|
4
4
|
|
@@ -22,7 +22,7 @@ logger = logging.getLogger(__name__)
|
|
22
22
|
|
23
23
|
|
24
24
|
class ManyMixin:
|
25
|
-
"""
|
25
|
+
"""Queries like `find many`."""
|
26
26
|
|
27
27
|
@classmethod
|
28
28
|
async def find_many(
|
@@ -49,7 +49,7 @@ class ManyMixin:
|
|
49
49
|
session: Any | None = None,
|
50
50
|
allow_disk_use: Any | None = None,
|
51
51
|
) -> list[dict[str, Any]]:
|
52
|
-
"""
|
52
|
+
"""Find documents."""
|
53
53
|
# Get collection for current model.
|
54
54
|
collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
|
55
55
|
# Correcting filter.
|
@@ -110,7 +110,7 @@ class ManyMixin:
|
|
110
110
|
session: Any | None = None,
|
111
111
|
allow_disk_use: Any | None = None,
|
112
112
|
) -> list[dict[str, Any]]:
|
113
|
-
"""
|
113
|
+
"""Find documents and convert to a raw documents.
|
114
114
|
|
115
115
|
Special changes:
|
116
116
|
_id to str
|
@@ -187,7 +187,7 @@ class ManyMixin:
|
|
187
187
|
session: Any | None = None,
|
188
188
|
allow_disk_use: Any | None = None,
|
189
189
|
) -> str | None:
|
190
|
-
"""
|
190
|
+
"""Find documents and convert to a json string."""
|
191
191
|
# Get collection for current model.
|
192
192
|
collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
|
193
193
|
# Correcting filter.
|
@@ -242,7 +242,7 @@ class ManyMixin:
|
|
242
242
|
let: Any | None = None,
|
243
243
|
comment: Any | None = None,
|
244
244
|
) -> DeleteResult:
|
245
|
-
"""
|
245
|
+
"""Find documents matching with Model."""
|
246
246
|
# Raises a panic if the Model cannot be removed.
|
247
247
|
if not cls.META["is_delete_doc"]:
|
248
248
|
msg = (
|
ramifice/commons/one.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Requests like `find one`."""
|
2
2
|
|
3
3
|
__all__ = ("OneMixin",)
|
4
4
|
|
@@ -20,7 +20,7 @@ logger = logging.getLogger(__name__)
|
|
20
20
|
|
21
21
|
|
22
22
|
class OneMixin:
|
23
|
-
"""
|
23
|
+
"""Requests like `find one`."""
|
24
24
|
|
25
25
|
@classmethod
|
26
26
|
async def find_one(
|
@@ -29,7 +29,7 @@ class OneMixin:
|
|
29
29
|
*args: tuple,
|
30
30
|
**kwargs: dict[str, Any],
|
31
31
|
) -> dict[str, Any] | None:
|
32
|
-
"""
|
32
|
+
"""Find a single document."""
|
33
33
|
# Get collection for current model.
|
34
34
|
collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
|
35
35
|
# Correcting filter.
|
@@ -51,7 +51,7 @@ class OneMixin:
|
|
51
51
|
*args: tuple,
|
52
52
|
**kwargs: dict[str, Any],
|
53
53
|
) -> dict[str, Any] | None:
|
54
|
-
"""
|
54
|
+
"""Find a single document and converting to raw document."""
|
55
55
|
# Get collection for current model.
|
56
56
|
collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
|
57
57
|
# Correcting filter.
|
@@ -78,7 +78,7 @@ class OneMixin:
|
|
78
78
|
*args: tuple,
|
79
79
|
**kwargs: dict[str, Any],
|
80
80
|
) -> Any | None:
|
81
|
-
"""
|
81
|
+
"""Find a single document and convert it to a Model instance."""
|
82
82
|
# Get collection for current model.
|
83
83
|
collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
|
84
84
|
# Correcting filter.
|
@@ -99,7 +99,7 @@ class OneMixin:
|
|
99
99
|
*args: tuple,
|
100
100
|
**kwargs: dict[str, Any],
|
101
101
|
) -> str | None:
|
102
|
-
"""
|
102
|
+
"""Find a single document and convert it to a JSON string."""
|
103
103
|
# Get collection for current model.
|
104
104
|
collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
|
105
105
|
# Correcting filter.
|
@@ -124,7 +124,7 @@ class OneMixin:
|
|
124
124
|
let: Any | None = None,
|
125
125
|
comment: Any | None = None,
|
126
126
|
) -> DeleteResult:
|
127
|
-
"""
|
127
|
+
"""Find a single document and delete it."""
|
128
128
|
# Raises a panic if the Model cannot be removed.
|
129
129
|
if not cls.META["is_delete_doc"]:
|
130
130
|
msg = (
|
@@ -162,7 +162,7 @@ class OneMixin:
|
|
162
162
|
comment: Any | None = None,
|
163
163
|
**kwargs: dict[str, Any],
|
164
164
|
) -> dict[str, Any] | None:
|
165
|
-
"""
|
165
|
+
"""Find a single document and delete it, return original."""
|
166
166
|
# Raises a panic if the Model cannot be removed.
|
167
167
|
if not cls.META["is_delete_doc"]:
|
168
168
|
msg = (
|
ramifice/commons/tools.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Tool of Commons - A set of auxiliary methods."""
|
2
2
|
|
3
3
|
__all__ = (
|
4
4
|
"correct_mongo_filter",
|
@@ -15,7 +15,7 @@ from ramifice.utils import translations
|
|
15
15
|
|
16
16
|
|
17
17
|
def correct_mongo_filter(cls_model: Any, filter: Any) -> Any:
|
18
|
-
"""
|
18
|
+
"""Correcting filter of request.
|
19
19
|
|
20
20
|
Corrects `TextField` fields that require localization of translation.
|
21
21
|
"""
|
@@ -33,7 +33,7 @@ def password_to_none(
|
|
33
33
|
field_name_and_type: dict[str, str],
|
34
34
|
mongo_doc: dict[str, Any],
|
35
35
|
) -> dict[str, Any]:
|
36
|
-
"""
|
36
|
+
"""Create object instance from Mongo document."""
|
37
37
|
for f_name, t_name in field_name_and_type.items():
|
38
38
|
if "PasswordField" == t_name:
|
39
39
|
mongo_doc[f_name] = None
|
@@ -45,7 +45,7 @@ def mongo_doc_to_raw_doc(
|
|
45
45
|
mongo_doc: dict[str, Any],
|
46
46
|
lang: str,
|
47
47
|
) -> dict[str, Any]:
|
48
|
-
"""
|
48
|
+
"""Convert the Mongo document to the raw document.
|
49
49
|
|
50
50
|
Special changes:
|
51
51
|
_id to str
|
ramifice/commons/unit_manager.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Units Management.
|
2
2
|
|
3
3
|
Management for `choices` parameter in dynamic field types.
|
4
4
|
"""
|
@@ -22,14 +22,14 @@ logger = logging.getLogger(__name__)
|
|
22
22
|
|
23
23
|
|
24
24
|
class UnitMixin:
|
25
|
-
"""
|
25
|
+
"""Units Management.
|
26
26
|
|
27
27
|
Management for `choices` parameter in dynamic field types.
|
28
28
|
"""
|
29
29
|
|
30
30
|
@classmethod
|
31
31
|
async def unit_manager(cls: Any, unit: Unit) -> None:
|
32
|
-
"""
|
32
|
+
"""Units Management.
|
33
33
|
|
34
34
|
Management for `choices` parameter in dynamic field types.
|
35
35
|
"""
|
ramifice/fields/__init__.py
CHANGED
ramifice/fields/bool_field.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Field of Model for enter boolean value."""
|
2
2
|
|
3
3
|
__all__ = ("BooleanField",)
|
4
4
|
|
@@ -6,24 +6,34 @@ import logging
|
|
6
6
|
|
7
7
|
from ramifice.fields.general.field import Field
|
8
8
|
from ramifice.utils import constants
|
9
|
-
from ramifice.utils.mixins
|
9
|
+
from ramifice.utils.mixins import JsonMixin
|
10
10
|
|
11
11
|
logger = logging.getLogger(__name__)
|
12
12
|
|
13
13
|
|
14
14
|
class BooleanField(Field, JsonMixin):
|
15
|
-
"""
|
15
|
+
"""Field of Model for enter boolean value.
|
16
|
+
|
17
|
+
Args:
|
18
|
+
label: Text label for a web form field.
|
19
|
+
default: Default value.
|
20
|
+
hide: Hide field from user.
|
21
|
+
disabled: Blocks access and modification of the element.
|
22
|
+
ignored: If true, the value of this field is not saved in the database.
|
23
|
+
hint: An alternative for the `placeholder` parameter.
|
24
|
+
warning: Warning information.
|
25
|
+
"""
|
16
26
|
|
17
27
|
def __init__( # noqa: D107
|
18
28
|
self,
|
19
29
|
label: str = "",
|
20
|
-
|
30
|
+
default: bool = False,
|
21
31
|
hide: bool = False,
|
32
|
+
disabled: bool = False,
|
22
33
|
ignored: bool = False,
|
23
34
|
hint: str = "",
|
24
35
|
warning: list[str] | None = None,
|
25
|
-
|
26
|
-
):
|
36
|
+
) -> None:
|
27
37
|
if constants.DEBUG:
|
28
38
|
try:
|
29
39
|
if default is not None and not isinstance(default, bool):
|
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Field of Model.
|
2
2
|
|
3
3
|
Type of selective float field with dynamic addition of elements.
|
4
4
|
"""
|
@@ -10,30 +10,40 @@ 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 ChoiceFloatDynField(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-One.
|
23
23
|
Element are (add|delete) via `ModelName.unit_manager(unit)` method.
|
24
|
+
|
25
|
+
Args:
|
26
|
+
label: Text label for a web form field.
|
27
|
+
hide: Hide field from user.
|
28
|
+
disabled: Blocks access and modification of the element.
|
29
|
+
ignored: If true, the value of this field is not saved in the database.
|
30
|
+
hint: An alternative for the `placeholder` parameter.
|
31
|
+
warning: Warning information.
|
32
|
+
required: Required field.
|
33
|
+
readonly: Specifies that the field cannot be modified by the user.
|
24
34
|
"""
|
25
35
|
|
26
36
|
def __init__( # noqa: D107
|
27
37
|
self,
|
28
38
|
label: str = "",
|
29
|
-
disabled: bool = False,
|
30
39
|
hide: bool = False,
|
40
|
+
disabled: bool = False,
|
31
41
|
ignored: bool = False,
|
32
42
|
hint: str = "",
|
33
43
|
warning: list[str] | None = None,
|
34
44
|
required: bool = False,
|
35
45
|
readonly: bool = False,
|
36
|
-
):
|
46
|
+
) -> None:
|
37
47
|
if constants.DEBUG:
|
38
48
|
try:
|
39
49
|
if not isinstance(label, str):
|
@@ -80,7 +90,7 @@ class ChoiceFloatDynField(Field, ChoiceGroup, JsonMixin):
|
|
80
90
|
self.choices: list[list[float | str]] | None = None
|
81
91
|
|
82
92
|
def has_value(self, is_migrate: bool = False) -> bool:
|
83
|
-
"""
|
93
|
+
"""Does the field value match the possible options in choices."""
|
84
94
|
if is_migrate:
|
85
95
|
return True
|
86
96
|
value = self.value
|
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Field of Model.
|
2
2
|
|
3
3
|
Type of selective float field with static of elements.
|
4
4
|
"""
|
@@ -10,31 +10,43 @@ 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 ChoiceFloatField(Field, ChoiceGroup, JsonMixin):
|
19
|
-
"""
|
19
|
+
"""Field of Model.
|
20
20
|
|
21
21
|
Type of selective integer float with static of elements.
|
22
22
|
With a single choice.
|
23
|
+
|
24
|
+
Args:
|
25
|
+
label: Text label for a web form field.
|
26
|
+
default: Default value.
|
27
|
+
hide: Hide field from user.
|
28
|
+
disabled: Blocks access and modification of the element.
|
29
|
+
required: Required field.
|
30
|
+
readonly: Specifies that the field cannot be modified by the user.
|
31
|
+
ignored: If true, the value of this field is not saved in the database.
|
32
|
+
hint: An alternative for the `placeholder` parameter.
|
33
|
+
warning: Warning information.
|
34
|
+
choices: For a predefined set of options - [[value, Title], ...].
|
23
35
|
"""
|
24
36
|
|
25
37
|
def __init__( # noqa: D107
|
26
38
|
self,
|
27
39
|
label: str = "",
|
28
|
-
|
40
|
+
default: float | None = None,
|
29
41
|
hide: bool = False,
|
42
|
+
disabled: bool = False,
|
30
43
|
ignored: bool = False,
|
31
44
|
hint: str = "",
|
32
45
|
warning: list[str] | None = None,
|
33
|
-
default: float | None = None,
|
34
46
|
required: bool = False,
|
35
47
|
readonly: bool = False,
|
36
|
-
choices: list[list[float | str]] | None = None,
|
37
|
-
):
|
48
|
+
choices: list[list[float | str]] | None = None, # [[value, Title], ...]
|
49
|
+
) -> None:
|
38
50
|
Field.__init__(
|
39
51
|
self,
|
40
52
|
label=label,
|
@@ -96,7 +108,7 @@ class ChoiceFloatField(Field, ChoiceGroup, JsonMixin):
|
|
96
108
|
raise err
|
97
109
|
|
98
110
|
def has_value(self, is_migrate: bool = False) -> bool:
|
99
|
-
"""
|
111
|
+
"""Does the field value match the possible options in choices."""
|
100
112
|
value = self.value
|
101
113
|
if value is None:
|
102
114
|
value = self.default
|
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Field of Model.
|
2
2
|
|
3
3
|
Type of selective float field with dynamic addition of elements.
|
4
4
|
"""
|
@@ -10,29 +10,39 @@ 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 ChoiceFloatMultDynField(Field, ChoiceGroup, JsonMixin):
|
19
|
-
"""
|
19
|
+
"""Field of Model.
|
20
20
|
|
21
21
|
Type of selective float field with dynamic addition of elements.
|
22
22
|
For simulate relationship Many-to-Many.
|
23
|
+
|
24
|
+
Args:
|
25
|
+
label: Text label for a web form field.
|
26
|
+
hide: Hide field from user.
|
27
|
+
disabled: Blocks access and modification of the element.
|
28
|
+
ignored: If true, the value of this field is not saved in the database.
|
29
|
+
hint: An alternative for the `placeholder` parameter.
|
30
|
+
warning: Warning information.
|
31
|
+
required: Required field.
|
32
|
+
readonly: Specifies that the field cannot be modified by the user.
|
23
33
|
"""
|
24
34
|
|
25
35
|
def __init__( # noqa: D107
|
26
36
|
self,
|
27
37
|
label: str = "",
|
28
|
-
disabled: bool = False,
|
29
38
|
hide: bool = False,
|
39
|
+
disabled: bool = False,
|
30
40
|
ignored: bool = False,
|
31
41
|
hint: str = "",
|
32
42
|
warning: list[str] | None = None,
|
33
43
|
required: bool = False,
|
34
44
|
readonly: bool = False,
|
35
|
-
):
|
45
|
+
) -> None:
|
36
46
|
if constants.DEBUG:
|
37
47
|
try:
|
38
48
|
if not isinstance(label, str):
|
@@ -80,7 +90,7 @@ class ChoiceFloatMultDynField(Field, ChoiceGroup, JsonMixin):
|
|
80
90
|
self.choices: list[list[float | str]] | None = None
|
81
91
|
|
82
92
|
def has_value(self, is_migrate: bool = False) -> bool:
|
83
|
-
"""
|
93
|
+
"""Does the field value match the possible options in choices."""
|
84
94
|
if is_migrate:
|
85
95
|
return True
|
86
96
|
value = self.value
|
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""Field of Model.
|
2
2
|
|
3
3
|
Type of selective float field with static of elements.
|
4
4
|
"""
|
@@ -10,31 +10,43 @@ 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 ChoiceFloatMultField(Field, ChoiceGroup, JsonMixin):
|
19
|
-
"""
|
19
|
+
"""Field of Model.
|
20
20
|
|
21
21
|
Type of selective float field with static of elements.
|
22
22
|
With multiple choice.
|
23
|
+
|
24
|
+
Args:
|
25
|
+
label: Text label for a web form field.
|
26
|
+
default: Default value.
|
27
|
+
hide: Hide field from user.
|
28
|
+
disabled: Blocks access and modification of the element.
|
29
|
+
ignored: If true, the value of this field is not saved in the database.
|
30
|
+
hint: An alternative for the `placeholder` parameter.
|
31
|
+
warning: Warning information.
|
32
|
+
required: Required field.
|
33
|
+
readonly: Specifies that the field cannot be modified by the user.
|
34
|
+
choices: For a predefined set of options - [[value, Title], ...].
|
23
35
|
"""
|
24
36
|
|
25
37
|
def __init__( # noqa: D107
|
26
38
|
self,
|
27
39
|
label: str = "",
|
28
|
-
|
40
|
+
default: list[float] | None = None,
|
29
41
|
hide: bool = False,
|
42
|
+
disabled: bool = False,
|
30
43
|
ignored: bool = False,
|
31
44
|
hint: str = "",
|
32
45
|
warning: list[str] | None = None,
|
33
|
-
default: list[float] | None = None,
|
34
46
|
required: bool = False,
|
35
47
|
readonly: bool = False,
|
36
|
-
choices: list[list[float | str]] | None = None,
|
37
|
-
):
|
48
|
+
choices: list[list[float | str]] | None = None, # [[value, Title], ...]
|
49
|
+
) -> None:
|
38
50
|
Field.__init__(
|
39
51
|
self,
|
40
52
|
label=label,
|
@@ -102,7 +114,7 @@ class ChoiceFloatMultField(Field, ChoiceGroup, JsonMixin):
|
|
102
114
|
raise err
|
103
115
|
|
104
116
|
def has_value(self, is_migrate: bool = False) -> bool:
|
105
|
-
"""
|
117
|
+
"""Does the field value match the possible options in choices."""
|
106
118
|
value = self.value
|
107
119
|
if value is None:
|
108
120
|
value = self.default
|