# HG changeset patch # User Paul Boddie # Date 1269214054 -3600 # Node ID f25c56d48bdb2483c478e80939d3fbe0239fcd0f # Parent 6138769c9ca221ba6b6d3f91041556e543dd6a72 Added support in the new event action for explicit time zones, simplifying the interface so that times are handled collectively (start plus end times), with time zone/regime information applying only individually where UTC offsets are concerned. Made various end time and date fields take information from the start fields by default. Fixed the action's HTML before the link details in the table. Added location information to the example template. Updated the release notes. diff -r 6138769c9ca2 -r f25c56d48bdb README.txt --- a/README.txt Wed Mar 17 01:36:28 2010 +0100 +++ b/README.txt Mon Mar 22 00:27:34 2010 +0100 @@ -213,6 +213,7 @@ replace the link information provided by the RSS and iCalendar summaries. * Fixed the production of the summaries when pages with no available edit log information are to be included. + * Added support for event times and time zone/regime information. New in EventAggregator 0.5 (Changes since EventAggregator 0.4) -------------------------------------------------------------- diff -r 6138769c9ca2 -r f25c56d48bdb actions/EventAggregatorNewEvent.py --- a/actions/EventAggregatorNewEvent.py Wed Mar 17 01:36:28 2010 +0100 +++ b/actions/EventAggregatorNewEvent.py Mon Mar 22 00:27:34 2010 +0100 @@ -15,6 +15,11 @@ from MoinMoin.PageEditor import PageEditor import EventAggregatorSupport +try: + import pytz +except ImportError: + pytz = None + Dependencies = ['pages'] # Action class and supporting functions. @@ -41,9 +46,18 @@ request = self.request form = request.form - # Handle advanced and basic forms. + # Handle advanced and basic forms, and enable/disable certain fields. show_advanced = form.get("advanced") and not form.get("basic") + show_end_date = form.get("end-day") and not form.get("hide-end-date") or form.get("show-end-date") + show_times = (form.get("start-hour") or form.get("end-hour")) and not form.get("hide-times") or form.get("show-times") + + show_zone_regime = form.get("regime") and not form.get("show-offsets") and \ + not form.get("hide-zone") or form.get("show-regime") + show_zone_offsets = form.get("start-offset") and not form.get("show-regime") and \ + not form.get("hide-zone") or form.get("show-offsets") + + show_zones = show_zone_regime or show_zone_offsets # Prepare the category list. @@ -79,45 +93,13 @@ del topics[i] break - # Initialise hour and minute lists. - - start_hour_list = [] - start_hour_list.append('') - start_minute_list = [] - start_minute_list.append('') - end_hour_list = [] - end_hour_list.append('') - end_minute_list = [] - end_minute_list.append('') - - start_hour = self._get_input(form, "start-hour") - end_hour = self._get_input(form, "end-hour") - start_minute = self._get_input(form, "start-minute") - end_minute = self._get_input(form, "end-minute") - - # Prepare hour and minute lists, selecting specified values. - - for hour in range(0, 24): - selected = self._get_selected(hour, start_hour) - start_hour_list.append('' % (hour, selected, hour)) - selected = self._get_selected(hour, end_hour) - end_hour_list.append('' % (hour, selected, hour)) - - for minute in range(0, 60): - selected = self._get_selected(minute, start_minute) - start_minute_list.append('' % (minute, selected, minute)) - selected = self._get_selected(minute, end_minute) - end_minute_list.append('' % (minute, selected, minute)) - # Initialise month lists. start_month_list = [] - start_month_list.append('') end_month_list = [] - end_month_list.append('') - start_month = self._get_input(form, "start-month", 0) - end_month = self._get_input(form, "end-month", 0) + start_month = self._get_input(form, "start-month", EventAggregatorSupport.getCurrentMonth()) + end_month = self._get_input(form, "end-month", start_month) # Prepare month lists, selecting specified months. @@ -128,6 +110,20 @@ selected = self._get_selected(month, end_month) end_month_list.append('' % (month, selected, month_label)) + # Initialise regime lists. + + regime_list = [] + regime_list.append('') + + regime = form.get("regime", [None])[0] + + # Prepare regime lists, selecting specified regimes. + + if pytz is not None: + for pytz_regime in pytz.common_timezones: + selected = self._get_selected(pytz_regime, regime) + regime_list.append('' % (pytz_regime, selected, pytz_regime)) + # Permitting configuration of the template name. template_default = getattr(request.cfg, "event_aggregator_new_event_template", "EventTemplate") @@ -138,24 +134,38 @@ "category_list" : "\n".join(category_list), "start_month_list" : "\n".join(start_month_list), - "start_hour_list" : "\n".join(start_hour_list), - "start_minute_list" : "\n".join(start_minute_list), + "end_month_list" : "\n".join(end_month_list), + + "regime_list" : "\n".join(regime_list), + "use_regime_label" : _("Using local time"), - "end_month_list" : "\n".join(end_month_list), - "end_hour_list" : "\n".join(end_hour_list), - "end_minute_list" : "\n".join(end_minute_list), + "show_end_date_label" : _("Specify end date"), + "hide_end_date_label" : _("End event on same day"), + + "show_times_label" : _("Specify times"), + "hide_times_label" : _("No start and end times"), + + "show_offsets_label" : _("Specify UTC offsets"), + "show_regime_label" : _("Specify location"), + "hide_zone_label" : _("Make times apply everywhere"), "start_label" : _("Start date (day, month, year)"), "start_day_default" : form.get("start-day", [""])[0], "start_year_default" : form.get("start-year", [""])[0] or EventAggregatorSupport.getCurrentYear(), "start_time_label" : _("Start time (hour, minute, second)"), + "start_hour_default" : form.get("start-hour", [""])[0], + "start_minute_default" : form.get("start-minute", [""])[0], "start_second_default" : form.get("start-second", [""])[0], + "start_offset_default" : form.get("start-offset", [""])[0], "end_label" : _("End date (day, month, year) - if different"), - "end_day_default" : form.get("end-day", [""])[0], - "end_year_default" : form.get("end-year", [""])[0], + "end_day_default" : form.get("end-day", [""])[0] or form.get("start-day", [""])[0], + "end_year_default" : form.get("end-year", [""])[0] or form.get("start-year", [""])[0], "end_time_label" : _("End time (hour, minute, second)"), + "end_hour_default" : form.get("end-hour", [""])[0], + "end_minute_default" : form.get("end-minute", [""])[0], "end_second_default" : form.get("end-second", [""])[0], + "end_offset_default" : form.get("end-offset", [""])[0] or form.get("start-offset", [""])[0], "title_label" : _("Event title/summary"), "title_default" : form.get("title", [""])[0], @@ -176,7 +186,7 @@ "parent_default" : form.get("parent", [""])[0], "advanced_label" : _("Show advanced options"), - "basic_label" : _("Show basic options"), + "basic_label" : _("Hide advanced options"), } # Prepare the output HTML. @@ -185,35 +195,28 @@ - - - - - - - + ''' % d + + # End date controls. + + if show_end_date: + html += ''' - - + + ''' % d + else: + html += ''' + + + ''' % d + + # Generic time information. + + if show_times: + + # Start time controls. + + html += ''' + + + ''' % d + + # Offset information displayed. + + if show_zone_offsets: + html += ''' ''' % d + + # Regime information displayed. + + elif show_zone_regime: + html += ''' + ''' % d + + html += ''' + ''' + + # End time controls. + + html += ''' + + + ''' % d + + # Offset information displayed. + + if show_zone_offsets: + html += ''' + ''' % d + + # Regime information displayed. + + elif show_zone_regime: + html += ''' + + ''' % d + + # Controls for removing times. + + html += ''' + + ''' % d + + # Time zone controls. + + if show_zones: + + # Offset information displayed. + + if show_zone_offsets: + html += ''' + ''' % d + + # No time zone information shown. + + else: + html += ''' + ''' % d + + html += ''' + ''' + + # Controls for adding times. + + else: + html += ''' + + + ''' % d + + + # Various basic controls. + + html += ''' + - - - - ''' % d @@ -261,7 +387,7 @@ html += ''' - @@ -270,7 +396,7 @@ html += ''' - ''' % d @@ -281,14 +407,14 @@ html += ''' - - - - - @@ -317,7 +443,7 @@ html += ''' - - @@ -377,8 +503,12 @@ link = form.get("link", [None])[0] topics = form.get("topics", []) - start_zone = form.get("start-zone", [None])[0] - end_zone = form.get("end-zone", [None])[0] + regime = form.get("regime", [None])[0] + start_offset = form.get("start-offset", [None])[0] + end_offset = form.get("end-offset", [None])[0] + + start_zone = regime or start_offset + end_zone = regime or end_offset # Validate certain fields. diff -r 6138769c9ca2 -r f25c56d48bdb pages/EventTemplate --- a/pages/EventTemplate Wed Mar 17 01:36:28 2010 +0100 +++ b/pages/EventTemplate Mon Mar 22 00:27:34 2010 +0100 @@ -3,6 +3,7 @@ Topics:: topics Description:: a brief description of the event for the RSS feed Link:: a link to a Web site for the event + Location:: the event location ## Summary:: summary/title ## To choose a title or summary different to the page name, or to ## provide a specific form of the page name, uncomment the above entry
+
+
- - - -
+
+ +
+ +
+ + + + - + + %(use_regime_label)s +
+ + + + + UTC + + - - -
+ + + ''' % d + + # Regime information displayed. + + elif show_zone_regime: + html += ''' + + ''' % d + + # To remove zone information. + + html += ''' + + + + +
+ +
+
+
+
+
+
+
+ @@ -296,19 +422,19 @@
+
+
+ %(buttons_html)s
+ %(category_list)s @@ -326,7 +452,7 @@
+ %(buttons_html)s