# HG changeset patch # User Paul Boddie # Date 1238353309 -7200 # Node ID 59ece334903a07b0ac730e915185d1fd488b8e4c # Parent b1eb7bf1655be6db6f5ba9de90ae37688d029068 Improved the form for the action to show months and to handle separate parameters for the start and end months. diff -r b1eb7bf1655b -r 59ece334903a EventAggregatorSupport.py --- a/EventAggregatorSupport.py Sun Mar 29 19:33:59 2009 +0200 +++ b/EventAggregatorSupport.py Sun Mar 29 21:01:49 2009 +0200 @@ -485,6 +485,9 @@ # User interface functions. +def getParameter(request, name): + return request.form.get(name, [None])[0] + def getParameterMonth(arg): n = None @@ -517,12 +520,20 @@ else: calendar_prefix = "%s-%s" % (calendar_name, argname) - arg = request.form.get(calendar_prefix, [None])[0] + arg = getParameter(request, calendar_prefix) if arg is not None: return getParameterMonth(arg) else: return None +def getFormMonthPair(request, yeararg, montharg): + year = getParameter(request, yeararg) + month = getParameter(request, montharg) + if year and month: + return (int(year), int(month)) + else: + return None + def getPrettyPageName(page): "Return a nicely formatted title/name for the given 'page'." diff -r b1eb7bf1655b -r 59ece334903a actions/EventAggregatorSummary.py --- a/actions/EventAggregatorSummary.py Sun Mar 29 19:33:59 2009 +0200 +++ b/actions/EventAggregatorSummary.py Sun Mar 29 21:01:49 2009 +0200 @@ -34,14 +34,24 @@ category_list.append('' % (category_pagename, category_name)) + month_list = [] + month_list.append('') + + for month in range(1, 13): + month_label = _(EventAggregatorSupport.getMonthLabel(month)) + month_list.append('' % (month, month_label)) + + year_label = [] + d = { "buttons_html" : buttons_html, "category_label" : _("Categories"), "category_list" : "\n".join(category_list), + "month_list" : "\n".join(month_list), "start_label" : _("Start year and month"), - "start_default" : "", + "start_year_default" : "", "end_label" : _("End year and month"), - "end_default" : "", + "end_year_default" : "", } return ''' @@ -57,13 +67,19 @@ - + + - + + @@ -80,11 +96,12 @@ "Write the iCalendar resource." _ = self._ + form = self.request.form # If no category names exist in the request, an error message is # returned. - category_names = self.request.form.get("category", []) + category_names = form.get("category", []) if not category_names: return 0, _("No categories specified.") @@ -117,6 +134,16 @@ calendar_start = EventAggregatorSupport.getFormMonth(request, None, "start") calendar_end = EventAggregatorSupport.getFormMonth(request, None, "end") + # Look for separate start and end years and months. + + form = request.form + + if calendar_start is None: + calendar_start = EventAggregatorSupport.getFormMonthPair(request, "start-year", "start-month") + + if calendar_end is None: + calendar_end = EventAggregatorSupport.getFormMonthPair(request, "end-year", "end-month") + events, shown_events, all_shown_events, earliest, latest = \ EventAggregatorSupport.getEvents(request, category_names, calendar_start, calendar_end)