0002-add-a-date-attribute-kind-fixes-10606.patch
src/authentic2/attribute_kinds.py | ||
---|---|---|
1 | 1 |
import string |
2 | 2 |
import json |
3 |
import datetime |
|
3 | 4 | |
4 | 5 |
from itertools import chain |
5 | 6 | |
... | ... | |
14 | 15 | |
15 | 16 |
from .decorators import to_iter |
16 | 17 |
from .plugins import collect_from_plugins |
17 |
from . import app_settings |
|
18 |
from . import app_settings, widgets
|
|
18 | 19 | |
19 | 20 |
capfirst = allow_lazy(capfirst, unicode) |
20 | 21 | |
... | ... | |
50 | 51 |
'serialize': lambda x: str(int(bool(x))), |
51 | 52 |
'deserialize': lambda x: bool(int(x)), |
52 | 53 |
}, |
54 |
{ |
|
55 |
'label': _('date'), |
|
56 |
'name': 'date', |
|
57 |
'field_class': forms.DateField, |
|
58 |
'kwargs': { |
|
59 |
'widget': widgets.DateWidget, |
|
60 |
}, |
|
61 |
'serialize': lambda x: x.isoformat(), |
|
62 |
'deserialize': lambda x: x and datetime.datetime.strptime(x, '%Y-%m-%d').date(), |
|
63 |
'rest_framework_field_class': serializers.DateField, |
|
64 |
}, |
|
53 | 65 |
] |
54 | 66 | |
55 | 67 | |
56 |
- |