1.1 --- a/EventAggregatorSupport.py Sun Jan 16 03:10:14 2011 +0100
1.2 +++ b/EventAggregatorSupport.py Sun Jan 16 19:30:01 2011 +0100
1.3 @@ -213,6 +213,17 @@
1.4
1.5 return start_year_default, end_year_default
1.6
1.7 + def get_day_defaults(self, default_as_current=0):
1.8 +
1.9 + "Return defaults for the start and end days."
1.10 +
1.11 + form = self.get_form()
1.12 +
1.13 + start_day_default = form.get("start-day", [default_as_current and getCurrentDate().day() or ""])[0]
1.14 + end_day_default = form.get("end-day", [default_as_current and start_day_default or ""])[0]
1.15 +
1.16 + return start_day_default, end_day_default
1.17 +
1.18 def get_form(request):
1.19
1.20 "Work around disruptive MoinMoin changes in 1.9."
1.21 @@ -1516,7 +1527,14 @@
1.22 return None
1.23
1.24 def getDate(s):
1.25 - return getDateTime(s).as_date()
1.26 +
1.27 + "Parse the string 's', extracting and returning a date object."
1.28 +
1.29 + dt = getDateTime(s)
1.30 + if dt is not None:
1.31 + return dt.as_date()
1.32 + else:
1.33 + return None
1.34
1.35 def getDateTime(s):
1.36
1.37 @@ -1694,6 +1712,22 @@
1.38 else:
1.39 return None
1.40
1.41 +def getFormDateTriple(request, yeararg, montharg, dayarg):
1.42 +
1.43 + """
1.44 + Return the date from the 'request' for the calendar with the given
1.45 + 'calendar_name' using the parameters having the given 'yeararg', 'montharg'
1.46 + and 'dayarg' names.
1.47 + """
1.48 +
1.49 + year = getParameter(request, yeararg)
1.50 + month = getParameter(request, montharg)
1.51 + day = getParameter(request, dayarg)
1.52 + if year and month and day:
1.53 + return Date((int(year), int(month), int(day)))
1.54 + else:
1.55 + return None
1.56 +
1.57 def getFormMonthPair(request, yeararg, montharg):
1.58
1.59 """
2.1 --- a/actions/EventAggregatorSummary.py Sun Jan 16 03:10:14 2011 +0100
2.2 +++ b/actions/EventAggregatorSummary.py Sun Jan 16 19:30:01 2011 +0100
2.3 @@ -2,7 +2,7 @@
2.4 """
2.5 MoinMoin - EventAggregatorSummary Action
2.6
2.7 - @copyright: 2008, 2009, 2010 by Paul Boddie <paul@boddie.org.uk>
2.8 + @copyright: 2008, 2009, 2010, 2011 by Paul Boddie <paul@boddie.org.uk>
2.9 @copyright: 2000-2004 Juergen Hermann <jh@web.de>,
2.10 2003-2008 MoinMoin:ThomasWaldmann,
2.11 2004-2006 MoinMoin:AlexanderSchremmer,
2.12 @@ -25,6 +25,17 @@
2.13
2.14 "A summary dialogue requesting various parameters."
2.15
2.16 + def get_evaluated_label(self, evaluated):
2.17 + _ = self._
2.18 + request = self.request
2.19 +
2.20 + if isinstance(evaluated, EventAggregatorSupport.Date):
2.21 + return EventAggregatorSupport.getFullDateLabel(request, evaluated)
2.22 + elif isinstance(evaluated, EventAggregatorSupport.Month):
2.23 + return EventAggregatorSupport.getFullMonthLabel(request, evaluated)
2.24 + else:
2.25 + return ""
2.26 +
2.27 def get_form_html(self, buttons_html):
2.28 _ = self._
2.29 request = self.request
2.30 @@ -42,9 +53,10 @@
2.31
2.32 category_list.append('<option value="%s" %s>%s</option>' % (category_pagename, selected, category_name))
2.33
2.34 - # Initialise month lists.
2.35 + # Initialise month lists and defaults.
2.36
2.37 start_month_list, end_month_list = self.get_month_lists()
2.38 + start_day_default, end_day_default = self.get_day_defaults()
2.39 start_year_default, end_year_default = self.get_year_defaults()
2.40
2.41 # Criteria instead of months and years.
2.42 @@ -52,13 +64,13 @@
2.43 start_criteria_default = form.get("start", [""])[0]
2.44 end_criteria_default = form.get("end", [""])[0]
2.45
2.46 - start_criteria_evaluated = EventAggregatorSupport.getParameterMonth(start_criteria_default)
2.47 - end_criteria_evaluated = EventAggregatorSupport.getParameterMonth(end_criteria_default)
2.48 + start_criteria_evaluated = EventAggregatorSupport.getParameterDate(start_criteria_default) or \
2.49 + EventAggregatorSupport.getParameterMonth(start_criteria_default)
2.50 + end_criteria_evaluated = EventAggregatorSupport.getParameterDate(end_criteria_default) or \
2.51 + EventAggregatorSupport.getParameterMonth(end_criteria_default)
2.52
2.53 - start_criteria_evaluated = start_criteria_evaluated and \
2.54 - EventAggregatorSupport.getFullMonthLabel(request, start_criteria_evaluated) or ""
2.55 - end_criteria_evaluated = end_criteria_evaluated and \
2.56 - EventAggregatorSupport.getFullMonthLabel(request, end_criteria_evaluated) or ""
2.57 + start_criteria_evaluated = self.get_evaluated_label(start_criteria_evaluated)
2.58 + end_criteria_evaluated = self.get_evaluated_label(end_criteria_evaluated)
2.59
2.60 # Descriptions.
2.61
2.62 @@ -85,14 +97,16 @@
2.63 "category_label" : _("Categories"),
2.64 "category_list" : "\n".join(category_list),
2.65 "start_month_list" : "\n".join(start_month_list),
2.66 - "start_label" : _("Start month and year"),
2.67 + "start_label" : _("Start day (optional), month and year"),
2.68 + "start_day_default" : start_day_default,
2.69 "start_year_default" : start_year_default,
2.70 "start_criteria_label" : _("or special criteria"),
2.71 "start_criteria_default": start_criteria_default,
2.72 "start_eval_label" : right_arrow,
2.73 "start_criteria_eval" : start_criteria_evaluated,
2.74 "end_month_list" : "\n".join(end_month_list),
2.75 - "end_label" : _("End month and year"),
2.76 + "end_label" : _("End day (optional), month and year"),
2.77 + "end_day_default" : end_day_default,
2.78 "end_year_default" : end_year_default,
2.79 "end_criteria_label" : _("or special criteria"),
2.80 "end_criteria_default" : end_criteria_default,
2.81 @@ -119,6 +133,7 @@
2.82 <tr>
2.83 <td class="label"><label>%(start_label)s</label></td>
2.84 <td>
2.85 + <input name="start-day" type="text" value="%(start_day_default)s" size="2" />
2.86 <select name="start-month">
2.87 %(start_month_list)s
2.88 </select>
2.89 @@ -136,6 +151,7 @@
2.90 <tr>
2.91 <td class="label"><label>%(end_label)s</label></td>
2.92 <td>
2.93 + <input name="end-day" type="text" value="%(end_day_default)s" size="2" />
2.94 <select name="end-month">
2.95 %(end_month_list)s
2.96 </select>
2.97 @@ -231,21 +247,38 @@
2.98 descriptions = form.get("descriptions", ["page"])[0]
2.99 parent = form.get("parent", [""])[0]
2.100
2.101 - # Otherwise, produce an iCalendar resource.
2.102 + calendar_start = EventAggregatorSupport.getFormDate(request, None, "start") or \
2.103 + EventAggregatorSupport.getFormMonth(request, None, "start")
2.104 + calendar_end = EventAggregatorSupport.getFormDate(request, None, "end") or \
2.105 + EventAggregatorSupport.getFormMonth(request, None, "end")
2.106
2.107 - calendar_start = EventAggregatorSupport.getFormMonth(request, None, "start")
2.108 - calendar_end = EventAggregatorSupport.getFormMonth(request, None, "end")
2.109 -
2.110 - # Look for separate start and end years and months.
2.111 + # Look for separate start and end parameters, either for complete dates
2.112 + # or for years and months.
2.113
2.114 if calendar_start is None:
2.115 - calendar_start = EventAggregatorSupport.getFormMonthPair(request, "start-year", "start-month")
2.116 + calendar_start = EventAggregatorSupport.getFormDateTriple(request, "start-year", "start-month", "start-day") or \
2.117 + EventAggregatorSupport.getFormMonthPair(request, "start-year", "start-month")
2.118
2.119 if calendar_end is None:
2.120 - calendar_end = EventAggregatorSupport.getFormMonthPair(request, "end-year", "end-month")
2.121 + calendar_end = EventAggregatorSupport.getFormDateTriple(request, "end-year", "end-month", "end-day") or \
2.122 + EventAggregatorSupport.getFormMonthPair(request, "end-year", "end-month")
2.123 +
2.124 + # Determine the period and get the events involved.
2.125 +
2.126 + if isinstance(calendar_start, EventAggregatorSupport.Date):
2.127 + if isinstance(calendar_end, EventAggregatorSupport.Date):
2.128 + mode = "day"
2.129 + else:
2.130 + calendar_start = calendar_start.as_month()
2.131 + mode = "month"
2.132 + else:
2.133 + mode = "month"
2.134 + if isinstance(calendar_end, EventAggregatorSupport.Date):
2.135 + calendar_end = calendar_end.as_month()
2.136
2.137 events, shown_events, all_shown_events, earliest, latest = \
2.138 - EventAggregatorSupport.getEvents(request, category_names, calendar_start, calendar_end)
2.139 + EventAggregatorSupport.getEvents(request, category_names, calendar_start, calendar_end,
2.140 + mode == "day" and "day" or "month")
2.141
2.142 latest_timestamp = EventAggregatorSupport.setEventTimestamps(request, all_shown_events)
2.143
2.144 @@ -327,6 +360,8 @@
2.145
2.146 request.write("END:VCALENDAR\r\n")
2.147
2.148 + # RSS output...
2.149 +
2.150 elif format == "RSS":
2.151
2.152 # Using the page name and the page URL in the title, link and