Mercurial > p > roundup > code
changeset 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 |
| files | CHANGES.txt roundup/cgi/templating.py |
| diffstat | 2 files changed, 16 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/CHANGES.txt Sat Feb 25 21:01:50 2017 -0500 +++ b/CHANGES.txt Sat Feb 25 22:21:15 2017 -0500 @@ -375,6 +375,9 @@ space separated list not comma separated. This fixes the format of the id url parameter when generated by indexargs_form. (John Rouillard) +- issue2550932 - html_calendar produces templating errors for bad date + strings. Fixed to ignore bad date and highlight todays date in the + calendar popup. 2016-01-11: 1.5.1
--- 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
