request_casting 0.6.0__tar.gz → 0.7.0__tar.gz

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.
@@ -1,18 +1,16 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: request_casting
3
- Version: 0.6.0
3
+ Version: 0.7.0
4
4
  Summary: Provide method to cast django request data for POST and GET methods
5
5
  License: GPL-3.0 license
6
6
  Author: turulomio
7
7
  Author-email: turulomio@yahoo.es
8
- Requires-Python: >3.8,<4.0
8
+ Requires-Python: >3.10,<4.0
9
9
  Classifier: License :: Other/Proprietary License
10
10
  Classifier: Programming Language :: Python :: 3
11
- Classifier: Programming Language :: Python :: 3.9
12
- Classifier: Programming Language :: Python :: 3.10
13
11
  Classifier: Programming Language :: Python :: 3.11
14
12
  Classifier: Programming Language :: Python :: 3.12
15
- Requires-Dist: pydicts (>=0.11.0)
13
+ Requires-Dist: pydicts (>=0.16.0)
16
14
  Description-Content-Type: text/markdown
17
15
 
18
16
  # request_casting
@@ -109,6 +107,19 @@ curl http://localhost:8000/myview/?a=2011-10-05T14:48:00.000Z => a will be a d
109
107
  curl http://localhost:8000/myview/?a=2021-1-1 => a will be None
110
108
  ```
111
109
 
110
+ ### RequestEmail
111
+ Use this method inside a view to get a validated email
112
+
113
+ ```python
114
+ # ... The same as RequestBool example
115
+ a=request_casting.RequestEmail(request, "a")
116
+ ```
117
+ You'll get this answers
118
+ ```
119
+ curl http://localhost:8000/myview/?a=hi@hi.com => a will be an email
120
+ curl http://localhost:8000/myview/?a=hi.hi.com => a will be None
121
+ ```
122
+
112
123
  ### RequestInteger
113
124
 
114
125
  Use this method inside a view to get a casted Integer
@@ -242,6 +253,13 @@ Run `poe coverage` to test module.
242
253
 
243
254
  ## Changelog
244
255
 
256
+ ### 0.7.0 (2024-04-13)
257
+ - Using pydicts-0.16.0
258
+ - Added RequestEmail method
259
+
260
+ ### 0.6.0 (2023-12-14)
261
+ - Using pydicts-0.11.0 library to capture errors and fix bugs
262
+
245
263
  ### 0.5.0 (2023-12-05)
246
264
  - Added support to request_casting with json formats (APICLIENT)
247
265
 
@@ -92,6 +92,19 @@ curl http://localhost:8000/myview/?a=2011-10-05T14:48:00.000Z => a will be a d
92
92
  curl http://localhost:8000/myview/?a=2021-1-1 => a will be None
93
93
  ```
94
94
 
95
+ ### RequestEmail
96
+ Use this method inside a view to get a validated email
97
+
98
+ ```python
99
+ # ... The same as RequestBool example
100
+ a=request_casting.RequestEmail(request, "a")
101
+ ```
102
+ You'll get this answers
103
+ ```
104
+ curl http://localhost:8000/myview/?a=hi@hi.com => a will be an email
105
+ curl http://localhost:8000/myview/?a=hi.hi.com => a will be None
106
+ ```
107
+
95
108
  ### RequestInteger
96
109
 
97
110
  Use this method inside a view to get a casted Integer
@@ -225,6 +238,13 @@ Run `poe coverage` to test module.
225
238
 
226
239
  ## Changelog
227
240
 
241
+ ### 0.7.0 (2024-04-13)
242
+ - Using pydicts-0.16.0
243
+ - Added RequestEmail method
244
+
245
+ ### 0.6.0 (2023-12-14)
246
+ - Using pydicts-0.11.0 library to capture errors and fix bugs
247
+
228
248
  ### 0.5.0 (2023-12-05)
229
249
  - Added support to request_casting with json formats (APICLIENT)
230
250
 
@@ -1,21 +1,21 @@
1
1
  [tool.poetry]
2
2
  name = "request_casting"
3
- version = "0.6.0"
3
+ version = "0.7.0"
4
4
  description = "Provide method to cast django request data for POST and GET methods"
5
5
  authors = ["turulomio <turulomio@yahoo.es>"]
6
6
  license = "GPL-3.0 license"
7
7
  readme = "README.md"
8
8
 
9
9
  [tool.poetry.dependencies]
10
- python = ">3.8,<4.0"
11
- pydicts = ">=0.11.0"
10
+ python = ">3.10,<4.0"
11
+ pydicts = ">=0.16.0"
12
12
 
13
13
  [tool.poetry.group.dev.dependencies]
14
- poetry = ">=1.5.1"
15
- poethepoet = ">=0.22.0"
16
- django = ">=4.2.7"
17
- djangorestframework = ">=3.14.0"
18
- coverage = ">=7.3.2"
14
+ poetry = ">=1.8.2"
15
+ poethepoet = ">=0.25.0"
16
+ django = ">=5.0.4"
17
+ djangorestframework = ">=3.15.1"
18
+ coverage = ">=7.4.4"
19
19
 
20
20
  [build-system]
21
21
  requires = ["poetry-core"]
@@ -1,4 +1,4 @@
1
1
  from datetime import datetime
2
- __version__="0.6.0"
3
- __version_datetime__=datetime(2023, 12, 14, 20, 39)
2
+ __version__="0.7.0"
3
+ __version_datetime__=datetime(2024, 4, 13, 11, 0)
4
4
  __version_date__=__version_datetime__.date()
@@ -8,7 +8,7 @@ msgid ""
8
8
  msgstr ""
9
9
  "Project-Id-Version: PACKAGE VERSION\n"
10
10
  "Report-Msgid-Bugs-To: \n"
11
- "POT-Creation-Date: 2023-12-14 20:40+0100\n"
11
+ "POT-Creation-Date: 2024-04-13 11:04+0200\n"
12
12
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -204,6 +204,20 @@ def RequestDtaware(request, field, timezone_string, default=None):
204
204
 
205
205
 
206
206
  return casts.str2dtaware(dictionary.get(field), "JsUtcIso", timezone_string, ignore_exception=True, ignore_exception_value=default)
207
+
208
+ def RequestEmail(request, field, default=None):
209
+ if request.method=="GET":
210
+ dictionary=request.GET
211
+ else:
212
+ dictionary=request.data
213
+
214
+ if not field in dictionary:
215
+ return default
216
+
217
+ if casts.is_email(dictionary.get(field)):
218
+ return dictionary.get(field)
219
+ else:
220
+ return default
207
221
 
208
222
  def RequestString(request, field, default=None):
209
223
  if request.method=="GET":
File without changes