Mercurial > p > roundup > code
comparison roundup/cgi/templating.py @ 4651:beb8d43f4d9d
issue2550765: Don't show links in calendar that will fail. Found and fixed by Cédric Krier.
| author | Bernhard Reiter <bernhard@intevation.de> |
|---|---|
| date | Wed, 01 Aug 2012 08:49:41 +0200 |
| parents | 11b6601629d7 |
| children | 57a64e591a00 |
comparison
equal
deleted
inserted
replaced
| 4650:0485b47a39a8 | 4651:beb8d43f4d9d |
|---|---|
| 2809 curr_date = date.Date(date_str) # to highlight | 2809 curr_date = date.Date(date_str) # to highlight |
| 2810 display = date.Date(display) # to show | 2810 display = date.Date(display) # to show |
| 2811 day = display.day | 2811 day = display.day |
| 2812 | 2812 |
| 2813 # for navigation | 2813 # for navigation |
| 2814 date_prev_month = display + date.Interval("-1m") | 2814 try: |
| 2815 date_next_month = display + date.Interval("+1m") | 2815 date_prev_month = display + date.Interval("-1m") |
| 2816 date_prev_year = display + date.Interval("-1y") | 2816 except ValueError: |
| 2817 date_next_year = display + date.Interval("+1y") | 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 | |
| 2818 | 2830 |
| 2819 res = [] | 2831 res = [] |
| 2820 | 2832 |
| 2821 base_link = "%s?@template=%s&property=%s&form=%s&date=%s" % \ | 2833 base_link = "%s?@template=%s&property=%s&form=%s&date=%s" % \ |
| 2822 (request.classname, template, property, form, curr_date) | 2834 (request.classname, template, property, form, curr_date) |
| 2824 # navigation | 2836 # navigation |
| 2825 # month | 2837 # month |
| 2826 res.append('<table class="calendar"><tr><td>') | 2838 res.append('<table class="calendar"><tr><td>') |
| 2827 res.append(' <table width="100%" class="calendar_nav"><tr>') | 2839 res.append(' <table width="100%" class="calendar_nav"><tr>') |
| 2828 link = "&display=%s"%date_prev_month | 2840 link = "&display=%s"%date_prev_month |
| 2829 res.append(' <td><a href="%s&display=%s"><</a></td>'%(base_link, | 2841 if date_prev_month: |
| 2830 date_prev_month)) | 2842 res.append(' <td><a href="%s&display=%s"><</a></td>' |
| 2843 % (base_link, date_prev_month)) | |
| 2844 else: | |
| 2845 res.append(' <td></td>') | |
| 2831 res.append(' <td>%s</td>'%calendar.month_name[display.month]) | 2846 res.append(' <td>%s</td>'%calendar.month_name[display.month]) |
| 2832 res.append(' <td><a href="%s&display=%s">></a></td>'%(base_link, | 2847 if date_next_month: |
| 2833 date_next_month)) | 2848 res.append(' <td><a href="%s&display=%s">></a></td>' |
| 2849 % (base_link, date_next_month)) | |
| 2850 else: | |
| 2851 res.append(' <td></td>') | |
| 2834 # spacer | 2852 # spacer |
| 2835 res.append(' <td width="100%"></td>') | 2853 res.append(' <td width="100%"></td>') |
| 2836 # year | 2854 # year |
| 2837 res.append(' <td><a href="%s&display=%s"><</a></td>'%(base_link, | 2855 if date_prev_year: |
| 2838 date_prev_year)) | 2856 res.append(' <td><a href="%s&display=%s"><</a></td>' |
| 2857 % (base_link, date_prev_year)) | |
| 2858 else: | |
| 2859 res.append(' <td></td>') | |
| 2839 res.append(' <td>%s</td>'%display.year) | 2860 res.append(' <td>%s</td>'%display.year) |
| 2840 res.append(' <td><a href="%s&display=%s">></a></td>'%(base_link, | 2861 if date_next_year: |
| 2841 date_next_year)) | 2862 res.append(' <td><a href="%s&display=%s">></a></td>' |
| 2863 % (base_link, date_next_year)) | |
| 2864 else: | |
| 2865 res.append(' <td></td>') | |
| 2842 res.append(' </tr></table>') | 2866 res.append(' </tr></table>') |
| 2843 res.append(' </td></tr>') | 2867 res.append(' </td></tr>') |
| 2844 | 2868 |
| 2845 # the calendar | 2869 # the calendar |
| 2846 res.append(' <tr><td><table class="calendar_display">') | 2870 res.append(' <tr><td><table class="calendar_display">') |
