Skip to content

Commit be7e43a

Browse files
committed
issue2550932 - html_calendar produces templating errors for bad date strings
Changed code to trap and ignore unparsible dates. The calendar starts with today highlighted.
1 parent 9e501e9 commit be7e43a

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,9 @@ Fixed:
375375
space separated list not comma separated. This fixes the format of
376376
the id url parameter when generated by indexargs_form. (John
377377
Rouillard)
378+
- issue2550932 - html_calendar produces templating errors for bad date
379+
strings. Fixed to ignore bad date and highlight todays date in the
380+
calendar popup.
378381

379382
2016-01-11: 1.5.1
380383

roundup/cgi/templating.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3031,8 +3031,19 @@ def html_calendar(self, request):
30313031
template = request.form.getfirst("@template", "calendar")
30323032
form = request.form.getfirst("form")
30333033
property = request.form.getfirst("property")
3034-
curr_date = date.Date(date_str) # to highlight
3035-
display = date.Date(display) # to show
3034+
curr_date = ""
3035+
try:
3036+
# date_str and display can be set to an invalid value
3037+
# if user submits a value like "d4" and gets an edit error.
3038+
# If either or both invalid just ignore that we can't parse it
3039+
# and assign them to today.
3040+
curr_date = date.Date(date_str) # to highlight
3041+
display = date.Date(display) # to show
3042+
except ValueError:
3043+
# we couldn't parse the date
3044+
# just let the calendar display
3045+
curr_date = current_date
3046+
display = current_date
30363047
day = display.day
30373048

30383049
# for navigation

0 commit comments

Comments
 (0)