Skip to content

Commit 06bab7a

Browse files
issue2550765: Don't show links in calendar that will fail. Found and fixed by Cédric Krier.
1 parent ed3b1a9 commit 06bab7a

File tree

2 files changed

+38
-12
lines changed

2 files changed

+38
-12
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Features:
1111

1212
Fixed:
1313

14+
- issue2550765: Don't show links in calendar that will fail.
15+
Found and fixed by C�dric Krier. (Bernhard)
1416
- "BaseException.with_traceback" is not available on Python 2, so use
1517
"raise E, V, T" instead of "raise E(V).with_traceback(T)". This change was
1618
originally introduced in 74476eaac38a. (Ezio Melotti)

roundup/cgi/templating.py

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2811,10 +2811,22 @@ def html_calendar(self, request):
28112811
day = display.day
28122812

28132813
# for navigation
2814-
date_prev_month = display + date.Interval("-1m")
2815-
date_next_month = display + date.Interval("+1m")
2816-
date_prev_year = display + date.Interval("-1y")
2817-
date_next_year = display + date.Interval("+1y")
2814+
try:
2815+
date_prev_month = display + date.Interval("-1m")
2816+
except ValueError:
2817+
date_prev_month = None
2818+
try:
2819+
date_next_month = display + date.Interval("+1m")
2820+
except ValueError:
2821+
date_next_month = None
2822+
try:
2823+
date_prev_year = display + date.Interval("-1y")
2824+
except ValueError:
2825+
date_prev_year = None
2826+
try:
2827+
date_next_year = display + date.Interval("+1y")
2828+
except ValueError:
2829+
date_next_year = None
28182830

28192831
res = []
28202832

@@ -2826,19 +2838,31 @@ def html_calendar(self, request):
28262838
res.append('<table class="calendar"><tr><td>')
28272839
res.append(' <table width="100%" class="calendar_nav"><tr>')
28282840
link = "&display=%s"%date_prev_month
2829-
res.append(' <td><a href="%s&display=%s">&lt;</a></td>'%(base_link,
2830-
date_prev_month))
2841+
if date_prev_month:
2842+
res.append(' <td><a href="%s&display=%s">&lt;</a></td>'
2843+
% (base_link, date_prev_month))
2844+
else:
2845+
res.append(' <td></td>')
28312846
res.append(' <td>%s</td>'%calendar.month_name[display.month])
2832-
res.append(' <td><a href="%s&display=%s">&gt;</a></td>'%(base_link,
2833-
date_next_month))
2847+
if date_next_month:
2848+
res.append(' <td><a href="%s&display=%s">&gt;</a></td>'
2849+
% (base_link, date_next_month))
2850+
else:
2851+
res.append(' <td></td>')
28342852
# spacer
28352853
res.append(' <td width="100%"></td>')
28362854
# year
2837-
res.append(' <td><a href="%s&display=%s">&lt;</a></td>'%(base_link,
2838-
date_prev_year))
2855+
if date_prev_year:
2856+
res.append(' <td><a href="%s&display=%s">&lt;</a></td>'
2857+
% (base_link, date_prev_year))
2858+
else:
2859+
res.append(' <td></td>')
28392860
res.append(' <td>%s</td>'%display.year)
2840-
res.append(' <td><a href="%s&display=%s">&gt;</a></td>'%(base_link,
2841-
date_next_year))
2861+
if date_next_year:
2862+
res.append(' <td><a href="%s&display=%s">&gt;</a></td>'
2863+
% (base_link, date_next_year))
2864+
else:
2865+
res.append(' <td></td>')
28422866
res.append(' </tr></table>')
28432867
res.append(' </td></tr>')
28442868

0 commit comments

Comments
 (0)