From 1271f0027801b125ce8806a1091b10f38e7e1e7e Mon Sep 17 00:00:00 2001 From: Tom Weber <60234929+alligatorbait@users.noreply.github.com> Date: Wed, 24 Feb 2021 07:19:37 -0700 Subject: [PATCH 1/2] String Check, catch NoneType error --- helpdesk/templatetags/helpdesk_util.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/helpdesk/templatetags/helpdesk_util.py b/helpdesk/templatetags/helpdesk_util.py index 67de5c26..937bb3ce 100644 --- a/helpdesk/templatetags/helpdesk_util.py +++ b/helpdesk/templatetags/helpdesk_util.py @@ -23,12 +23,12 @@ def datetime_string_format(value): """ try: new_value = date_filter(datetime.strptime(value, CUSTOMFIELD_DATETIME_FORMAT), settings.DATETIME_FORMAT) - except ValueError: + except (TypeError, ValueError): try: new_value = date_filter(datetime.strptime(value, CUSTOMFIELD_DATE_FORMAT), settings.DATE_FORMAT) - except ValueError: + except (TypeError, ValueError): try: new_value = date_filter(datetime.strptime(value, CUSTOMFIELD_TIME_FORMAT), settings.TIME_FORMAT) - except ValueError: + except (TypeError, ValueError): new_value = value return new_value From 9e3466a069404d8a97508281b605d12650c7298b Mon Sep 17 00:00:00 2001 From: Tom Weber <60234929+alligatorbait@users.noreply.github.com> Date: Wed, 24 Feb 2021 08:20:27 -0700 Subject: [PATCH 2/2] String Check, replace Nonetype with empty string --- helpdesk/templatetags/helpdesk_util.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/helpdesk/templatetags/helpdesk_util.py b/helpdesk/templatetags/helpdesk_util.py index 937bb3ce..3ad345d4 100644 --- a/helpdesk/templatetags/helpdesk_util.py +++ b/helpdesk/templatetags/helpdesk_util.py @@ -30,5 +30,6 @@ def datetime_string_format(value): try: new_value = date_filter(datetime.strptime(value, CUSTOMFIELD_TIME_FORMAT), settings.TIME_FORMAT) 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