diff roundup/cgi/templating.py @ 5191:fe52cab8f5b5

issue2550932 - html_calendar produces templating errors for bad date strings Changed code to trap and ignore unparsible dates. The calendar starts with today highlighted.
author John Rouillard <rouilj@ieee.org>
date Sat, 25 Feb 2017 22:21:15 -0500
parents 89b1870b1bc9
children 302e3a1a7190
line wrap: on
line diff
--- a/roundup/cgi/templating.py	Sat Feb 25 21:01:50 2017 -0500
+++ b/roundup/cgi/templating.py	Sat Feb 25 22:21:15 2017 -0500
@@ -3031,8 +3031,19 @@
         template  = request.form.getfirst("@template", "calendar")
         form      = request.form.getfirst("form")
         property  = request.form.getfirst("property")
-        curr_date = date.Date(date_str) # to highlight
-        display   = date.Date(display)  # to show
+        curr_date = ""
+        try:
+            # date_str and display can be set to an invalid value
+            # if user submits a value like "d4" and gets an edit error.
+            # If either or both invalid just ignore that we can't parse it
+            # and assign them to today.
+            curr_date = date.Date(date_str) # to highlight
+            display   = date.Date(display)  # to show
+        except ValueError:
+            # we couldn't parse the date
+            # just let the calendar display
+            curr_date = current_date
+            display = current_date
         day       = display.day
 
         # for navigation

Roundup Issue Tracker: http://roundup-tracker.org/