Fix deserialize logic for jQuery time-picker widget
This commit is contained in:
parent
1e8a4534d5
commit
abd47ae7ae
|
@ -26,8 +26,10 @@ Form Widgets
|
|||
|
||||
from __future__ import unicode_literals, absolute_import
|
||||
|
||||
import six
|
||||
import json
|
||||
import datetime
|
||||
|
||||
import six
|
||||
|
||||
import colander
|
||||
from deform import widget as dfwidget
|
||||
|
@ -85,6 +87,18 @@ class JQueryTimeWidget(dfwidget.TimeInputWidget):
|
|||
('showPeriod', True),
|
||||
)
|
||||
|
||||
def deserialize(self, field, pstruct):
|
||||
if pstruct in ('', colander.null):
|
||||
return colander.null
|
||||
try:
|
||||
validated = self._pstruct_schema.deserialize(pstruct)
|
||||
except colander.Invalid as exc:
|
||||
raise colander.Invalid(field.schema, "Invalid pstruct: %s" % exc)
|
||||
value = validated['time_submit'] or validated['time']
|
||||
if value:
|
||||
value = datetime.datetime.strptime(value, '%I:%M %p').strftime('%H:%M')
|
||||
return value
|
||||
|
||||
|
||||
class JQueryAutocompleteWidget(dfwidget.AutocompleteInputWidget):
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue