wbcore 1.59.13__py2.py3-none-any.whl → 1.59.15__py2.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.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from datetime import date, datetime, timedelta
|
|
2
2
|
|
|
3
3
|
import pytz
|
|
4
|
+
from django.core.exceptions import ValidationError
|
|
4
5
|
from psycopg.types.range import DateRange, TimestampRange, TimestamptzRange
|
|
5
6
|
from rest_framework import serializers
|
|
6
7
|
from rest_framework.settings import api_settings
|
|
@@ -36,9 +37,28 @@ class ShortcutMixin(WBCoreSerializerFieldMixin):
|
|
|
36
37
|
return key, representation
|
|
37
38
|
|
|
38
39
|
|
|
40
|
+
class DateRangeBoundedValidator:
|
|
41
|
+
"""
|
|
42
|
+
Ensure a psycopg DateRange has both lower and upper bounds set (no None).
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
def __call__(self, value):
|
|
46
|
+
# Accept empty values the usual DRF way; let `required` handle presence.
|
|
47
|
+
if value is None:
|
|
48
|
+
return
|
|
49
|
+
|
|
50
|
+
# DateRange / DateTimeTZRange objects expose .lower and .upper. [web:30][web:44]
|
|
51
|
+
lower = getattr(value, "lower", None)
|
|
52
|
+
upper = getattr(value, "upper", None)
|
|
53
|
+
|
|
54
|
+
if lower is None or upper is None:
|
|
55
|
+
raise ValidationError("This range must have both a lower and an upper bound.")
|
|
56
|
+
|
|
57
|
+
|
|
39
58
|
class DateRangeField(RangeMixin, ShortcutMixin, serializers.DateField):
|
|
40
59
|
field_type = WBCoreType.DATERANGE.value
|
|
41
60
|
internal_field = DateRange
|
|
61
|
+
default_validators = [DateRangeBoundedValidator()]
|
|
42
62
|
|
|
43
63
|
def __init__(
|
|
44
64
|
self,
|
|
@@ -78,6 +98,7 @@ class DateRangeField(RangeMixin, ShortcutMixin, serializers.DateField):
|
|
|
78
98
|
class DateTimeRangeField(RangeMixin, ShortcutMixin, serializers.DateTimeField):
|
|
79
99
|
field_type = WBCoreType.DATETIMERANGE.value
|
|
80
100
|
internal_field = TimestamptzRange
|
|
101
|
+
default_validators = [DateRangeBoundedValidator()]
|
|
81
102
|
|
|
82
103
|
def __init__(self, *args, lower_time_choices=None, upper_time_choices=None, **kwargs):
|
|
83
104
|
self.lower_time_choices = lower_time_choices
|
|
@@ -1106,7 +1106,7 @@ wbcore/serializers/utils.py,sha256=H_faApLg6bNiZvZNvApZhmVBJ07obw1u5QKZx7DLLa8,4
|
|
|
1106
1106
|
wbcore/serializers/fields/__init__.py,sha256=xNNak0yl8FtC6m-__B5mfieSNGAygXND34E_HrJ2Fcw,1498
|
|
1107
1107
|
wbcore/serializers/fields/boolean.py,sha256=vwP7HQflArFEG0w9FfXkPYKreFJ5qMjs-L0qKMeKCVQ,1682
|
|
1108
1108
|
wbcore/serializers/fields/choice.py,sha256=ozVwKaPCpsgPuQXQWr8TxHIcxSdGvhw23OFVD0xnipg,2128
|
|
1109
|
-
wbcore/serializers/fields/datetime.py,sha256=
|
|
1109
|
+
wbcore/serializers/fields/datetime.py,sha256=cHJNQyR5Xx9Z7AQEBpmRB7obRRwqAiMZeVzdPo0udts,8151
|
|
1110
1110
|
wbcore/serializers/fields/fields.py,sha256=R_JJxnSfgKK6pYFgfe_-7qo_y25YksQ-WuNgiKWev4U,7068
|
|
1111
1111
|
wbcore/serializers/fields/file.py,sha256=tDDK2bITiP7zxl9Ilzja2_gWae_lf9CkO1rDEBPaj6g,568
|
|
1112
1112
|
wbcore/serializers/fields/fsm.py,sha256=xUYxDj166PDnmDLggI4fShXdSunJVzbc8quFQioM3Yc,700
|
|
@@ -1238,6 +1238,6 @@ wbcore/viewsets/generics.py,sha256=lKDq9UY_Tyc56u1bqaIEvHGgoaXwXxpZ1c3fLVteptI,1
|
|
|
1238
1238
|
wbcore/viewsets/mixins.py,sha256=IdHd_uixOv3ExKoHxTgL5Bt8OELIwfYwhBZm0nsvZfc,12054
|
|
1239
1239
|
wbcore/viewsets/utils.py,sha256=4520Ij3ASM8lOa8QZkCqbBfOexVRiZu688eW-PGqMOA,882
|
|
1240
1240
|
wbcore/viewsets/viewsets.py,sha256=FPPESunEjlunDr5VFsjTfsquTS3iDSQkw0H6QjMKPqk,6574
|
|
1241
|
-
wbcore-1.59.
|
|
1242
|
-
wbcore-1.59.
|
|
1243
|
-
wbcore-1.59.
|
|
1241
|
+
wbcore-1.59.15.dist-info/METADATA,sha256=uvZthr2nShlETo8smG6-1ovWfvA5Bi-DJahDYgloGsc,2317
|
|
1242
|
+
wbcore-1.59.15.dist-info/WHEEL,sha256=aha0VrrYvgDJ3Xxl3db_g_MDIW-ZexDdrc_m-Hk8YY4,105
|
|
1243
|
+
wbcore-1.59.15.dist-info/RECORD,,
|
|
File without changes
|