mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2024-12-12 18:00:45 +01:00
Merge pull request #948 from alligatorbait/master
String Check, catch NoneType error
This commit is contained in:
commit
78a027b5a8
@ -23,12 +23,13 @@ def datetime_string_format(value):
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
new_value = date_filter(datetime.strptime(value, CUSTOMFIELD_DATETIME_FORMAT), settings.DATETIME_FORMAT)
|
new_value = date_filter(datetime.strptime(value, CUSTOMFIELD_DATETIME_FORMAT), settings.DATETIME_FORMAT)
|
||||||
except ValueError:
|
except (TypeError, ValueError):
|
||||||
try:
|
try:
|
||||||
new_value = date_filter(datetime.strptime(value, CUSTOMFIELD_DATE_FORMAT), settings.DATE_FORMAT)
|
new_value = date_filter(datetime.strptime(value, CUSTOMFIELD_DATE_FORMAT), settings.DATE_FORMAT)
|
||||||
except ValueError:
|
except (TypeError, ValueError):
|
||||||
try:
|
try:
|
||||||
new_value = date_filter(datetime.strptime(value, CUSTOMFIELD_TIME_FORMAT), settings.TIME_FORMAT)
|
new_value = date_filter(datetime.strptime(value, CUSTOMFIELD_TIME_FORMAT), settings.TIME_FORMAT)
|
||||||
except ValueError:
|
except (TypeError, ValueError):
|
||||||
new_value = value
|
# If NoneType return empty string, else return original value
|
||||||
|
new_value = "" if value is None else value
|
||||||
return new_value
|
return new_value
|
||||||
|
Loading…
Reference in New Issue
Block a user