ramifice 0.8.15__py3-none-any.whl → 0.8.16__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/models/model.py +9 -0
- {ramifice-0.8.15.dist-info → ramifice-0.8.16.dist-info}/METADATA +12 -10
- {ramifice-0.8.15.dist-info → ramifice-0.8.16.dist-info}/RECORD +5 -5
- {ramifice-0.8.15.dist-info → ramifice-0.8.16.dist-info}/WHEEL +0 -0
- {ramifice-0.8.15.dist-info → ramifice-0.8.16.dist-info}/licenses/LICENSE +0 -0
ramifice/models/model.py
CHANGED
@@ -188,3 +188,12 @@ class Model(metaclass=ABCMeta):
|
|
188
188
|
elif group == "id":
|
189
189
|
value = ObjectId(value)
|
190
190
|
self.__dict__[name].value = value
|
191
|
+
|
192
|
+
# --------------------------------------------------------------------------
|
193
|
+
def get_clean_data(self) -> dict[str, Any]:
|
194
|
+
"""Get clean data."""
|
195
|
+
clean_data: dict[str, Any] = {}
|
196
|
+
for name, data in self.__dict__.items():
|
197
|
+
if not callable(data):
|
198
|
+
clean_data[name] = data.value
|
199
|
+
return clean_data
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ramifice
|
3
|
-
Version: 0.8.
|
3
|
+
Version: 0.8.16
|
4
4
|
Summary: ORM-pseudo-like API MongoDB for Python language.
|
5
5
|
Project-URL: Homepage, https://github.com/kebasyaty/ramifice
|
6
6
|
Project-URL: Documentation, https://kebasyaty.github.io/ramifice/
|
@@ -132,6 +132,7 @@ It is recommended to look at examples [here](https://github.com/kebasyaty/ramifi
|
|
132
132
|
```python
|
133
133
|
import re
|
134
134
|
import asyncio
|
135
|
+
from typing import Any
|
135
136
|
from datetime import datetime
|
136
137
|
import pprint
|
137
138
|
|
@@ -187,23 +188,21 @@ class User:
|
|
187
188
|
ignored=True,
|
188
189
|
)
|
189
190
|
|
190
|
-
|
191
|
-
# Optional method.
|
191
|
+
# Optional method
|
192
192
|
async def add_validation(self) -> dict[str, str]:
|
193
193
|
"""Additional validation of fields."""
|
194
194
|
gettext = translations.gettext
|
195
195
|
error_map: dict[str, str] = {}
|
196
196
|
|
197
|
-
# Get clean data
|
198
|
-
|
199
|
-
username = self.username.value
|
200
|
-
password = self.password.value
|
201
|
-
сonfirm_password = self.сonfirm_password.value
|
197
|
+
# Get clean data
|
198
|
+
cd: dict[str, Any] = self.get_clean_data()
|
202
199
|
|
203
|
-
|
200
|
+
# Check username
|
201
|
+
if re.match(r"^[a-zA-Z0-9_]+$", cd["username"]) is None:
|
204
202
|
error_map["username"] = gettext("Allowed chars: %s") % "a-z A-Z 0-9 _"
|
205
203
|
|
206
|
-
|
204
|
+
# Check password
|
205
|
+
if cd["id"] is None and (cd["password"] != cd["сonfirm_password"]):
|
207
206
|
error_map["password"] = gettext("Passwords do not match!")
|
208
207
|
return error_map
|
209
208
|
|
@@ -255,6 +254,9 @@ async def main():
|
|
255
254
|
# (if necessary)
|
256
255
|
# await User.collection().drop()
|
257
256
|
|
257
|
+
# Close connection.
|
258
|
+
await client.close()
|
259
|
+
|
258
260
|
|
259
261
|
if __name__ == "__main__":
|
260
262
|
asyncio.run(main())
|
@@ -45,7 +45,7 @@ ramifice/fields/general/number_group.py,sha256=jspiA9hWiU_hNhXbTku2rZG3UezrhEVBG
|
|
45
45
|
ramifice/fields/general/text_group.py,sha256=hYVX4-ipD2_eyj-WpHIHnFrpQevySaVd4twffUsrOLo,1164
|
46
46
|
ramifice/models/__init__.py,sha256=y5jRhSzcPuEVUWr1u--o1GyjFb7irlf5Rn2gPvQ3IPg,26
|
47
47
|
ramifice/models/decorator.py,sha256=PX6b8DTP_Qz1SjyPcZ1vGDS4AGRZ6ZD8z8y6497j-DM,6685
|
48
|
-
ramifice/models/model.py,sha256=
|
48
|
+
ramifice/models/model.py,sha256=Q2FG0zBNCIPEQZXLEj_l2kB-6LT0acFKoBVU7hYiDPE,7717
|
49
49
|
ramifice/paladins/__init__.py,sha256=I2FzvCrp6upv_GPLfDqaVLwIT6-3Dp_K9i51tFUXDuc,673
|
50
50
|
ramifice/paladins/check.py,sha256=mxvnHR9EG7eQrGOE7wph1lCUq3jf2RF0Ovhhtz7W3g8,6974
|
51
51
|
ramifice/paladins/delete.py,sha256=Ynew5zvEBRJNmss5I8hSIp7KgBHpSvDEJCwOfMH5MUU,3723
|
@@ -78,7 +78,7 @@ ramifice/utils/mixins/add_valid.py,sha256=vYq4wGdpfA4iLMts7G0NvDALZBwupOScsajDFW
|
|
78
78
|
ramifice/utils/mixins/hooks.py,sha256=h8coNstWWHI4VwPgpjx0NWTj93-5NDAGtav0VFh-fk4,1031
|
79
79
|
ramifice/utils/mixins/indexing.py,sha256=WVLxmkLKg-C_LHn2hq6LJuOkSr9eS-XUUvCMgK-pKYo,387
|
80
80
|
ramifice/utils/mixins/json_converter.py,sha256=qBqFYol3Pbq1kX33EWB6FsYUL3AGSdYNtQE97HQ9jy4,1225
|
81
|
-
ramifice-0.8.
|
82
|
-
ramifice-0.8.
|
83
|
-
ramifice-0.8.
|
84
|
-
ramifice-0.8.
|
81
|
+
ramifice-0.8.16.dist-info/METADATA,sha256=ySscCHH2SOY5PCObHgagtPdTrzdwQSeQNYCaj-8GRxU,20961
|
82
|
+
ramifice-0.8.16.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
83
|
+
ramifice-0.8.16.dist-info/licenses/LICENSE,sha256=LrEL0aTZx90HDwFUQCJutORiDjJL9AnuVvCtspXIqt4,1095
|
84
|
+
ramifice-0.8.16.dist-info/RECORD,,
|
File without changes
|
File without changes
|