# HG changeset patch # User Paul Boddie # Date 1331248178 -3600 # Node ID f59288d38cad1dcbe6fb6bbe3d216bfff1a1906f # Parent 0d24005499ef10992a42815e0a16e48f53d9d3fa Introduced selection of locations from the list of known locations when creating new events. Tidied up the new event form to allow location information to be applied as widely as possible, hiding confusing options when a known location is selected. Added support for specifying time zone/regime information in the locations dictionary. Added an abstraction for locations obtained from the dictionary. Made an option list convenience method for forms used in actions. Updated the help for new events and the locations dictionary, adding time zone/regime details to locations in the provided dictionary. Updated the release notes. diff -r 0d24005499ef -r f59288d38cad EventAggregatorSupport.py --- a/EventAggregatorSupport.py Sat Feb 18 16:37:58 2012 +0100 +++ b/EventAggregatorSupport.py Fri Mar 09 00:09:38 2012 +0100 @@ -85,7 +85,7 @@ return category_regexp def getWikiDict(pagename, request): - if Page(request, pagename).exists() and request.user.may.read(pagename): + if pagename and Page(request, pagename).exists() and request.user.may.read(pagename): if hasattr(request.dicts, "dict"): return request.dicts.dict(pagename) else: @@ -124,6 +124,20 @@ "Extend the generic action support." + def get_option_list(self, value, values): + + """ + Return a list of HTML element definitions for options describing the + given 'values', selecting the option with the specified 'value' if + present. + """ + + options = [] + for available_value in values: + selected = self._get_selected(available_value, value) + options.append('' % (escattr(available_value), selected, escape(available_value))) + return options + def get_month_lists(self, default_as_current=0): """ @@ -1365,6 +1379,63 @@ return new_event_page.getBody() +def getMapsPage(request): + return getattr(request.cfg, "event_aggregator_maps_page", "EventMapsDict") + +def getLocationsPage(request): + return getattr(request.cfg, "event_aggregator_locations_page", "EventLocationsDict") + +class Location: + + """ + A representation of a location acquired from the locations dictionary. + + The locations dictionary is a mapping from location to a string containing + white-space-separated values describing... + + * The latitude and longitude of the location. + * Optionally, the time regime used by the location. + """ + + def __init__(self, location, locations): + + """ + Initialise the given 'location' using the 'locations' dictionary + provided. + """ + + self.location = location + + try: + self.data = locations[location].split() + except KeyError: + self.data = [] + + def getPosition(self): + + """ + Attempt to return the position of this location. If no position can be + found, return a latitude of None and a longitude of None. + """ + + try: + latitude, longitude = map(getMapReference, self.data[:2]) + return latitude, longitude + except ValueError: + return None, None + + def getTimeRegime(self): + + """ + Attempt to return the time regime employed at this location. If no + regime has been specified, return None. + """ + + try: + return self.data[2] + except IndexError: + return None + # Colour-related functions. def getColour(s): @@ -2820,8 +2891,8 @@ # Special dictionary pages. - maps_page = getattr(request.cfg, "event_aggregator_maps_page", "EventMapsDict") - locations_page = getattr(request.cfg, "event_aggregator_locations_page", "EventLocationsDict") + maps_page = getMapsPage(request) + locations_page = getLocationsPage(request) map_image = None @@ -2894,7 +2965,7 @@ # page. else: - latitude, longitude = getLocationPosition(location, locations) + latitude, longitude = Location(location, locations).getPosition() # Use a normalised location if necessary. diff -r 0d24005499ef -r f59288d38cad README.txt --- a/README.txt Sat Feb 18 16:37:58 2012 +0100 +++ b/README.txt Fri Mar 09 00:09:38 2012 +0100 @@ -309,11 +309,20 @@ time zone information for the correct interpretation of time information in those summaries. Thus, it is highly recommended that pytz be installed. -New in EventAggregator 0.9 (Changes since EventAggregator 0.8.2) +New in EventAggregator 0.9 (Changes since EventAggregator 0.8.3) ---------------------------------------------------------------- * Moved much of the support library to the MoinSupport distribution, thus introducing a dependency on that software. + * Added support for in-page updates of the event views so that navigation + between days, months and different views does not cause a full-page + reload if JavaScript is enabled. + * Tidied up the new event form, showing a list of known locations for + selection, making the event location affect the chosen time zone/regime if + the location is known, and hiding latitude and longitude fields unless an + unknown location is to be specified. + * The EventLocationsDict or equivalent can now retain time zone/regime + information about each location. New in EventAggregator 0.8.3 (Changes since EventAggregator 0.8.2) ------------------------------------------------------------------ diff -r 0d24005499ef -r f59288d38cad TO_DO.txt --- a/TO_DO.txt Sat Feb 18 16:37:58 2012 +0100 +++ b/TO_DO.txt Fri Mar 09 00:09:38 2012 +0100 @@ -21,12 +21,6 @@ Consider making dates convertible to timespans of the form (start of day, start of next day). -Location Selection ------------------- - -A menu of locations derived from the EventLocationsDict could be shown by the -new event action. - Localised Keywords ------------------ diff -r 0d24005499ef -r f59288d38cad actions/EventAggregatorNewEvent.py --- a/actions/EventAggregatorNewEvent.py Sat Feb 18 16:37:58 2012 +0100 +++ b/actions/EventAggregatorNewEvent.py Fri Mar 09 00:09:38 2012 +0100 @@ -39,13 +39,7 @@ 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 + show_location = form.get("show-location") or form.get("new-location") and not form.get("hide-location") # Prepare the category list. @@ -84,19 +78,56 @@ start_month_list, end_month_list = self.get_month_lists(default_as_current=1) start_year_default, end_year_default = self.get_year_defaults(default_as_current=1) + # Initialise the locations list. + + locations_page = getLocationsPage(request) + locations = getWikiDict(locations_page, request) + + locations_list = [] + locations_list.append('') + + location = (form.get("location") or form.get("new-location") or [""])[0] + + # Prepare the locations list, selecting the specified location. + + if locations: + locations_list += self.get_option_list(location, locations) or [] + + locations_list.sort() + + # Initialise the time regime from the location. + + regime = form.get("regime", [None])[0] + + if not regime: + regime = Location(location, locations).getTimeRegime() + # Initialise regime lists. regime_list = [] - regime_list.append('') - - regime = form.get("regime", [None])[0] + regime_list.append('' % escape(_(""))) # 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('' % (escattr(pytz_regime), selected, escape(pytz_regime))) + regime_list += self.get_option_list(regime, pytz.common_timezones) + + # Show time zone-related information depending on various fields. + + show_zone_regime = ( + (form.get("regime") or regime) # have a regime value + and not form.get("show-offsets") # are not switching to offsets + and not form.get("hide-zone") # are not removing zone information + or form.get("show-regime") # are switching to a regime + ) + show_zone_offsets = ( + form.get("start-offset") # have an offset + and not form.get("show-regime") # are not switching to a regime + and not form.get("hide-zone") # are not removing zone information + or form.get("show-offsets") # are switching to offsets + ) + + show_zones = show_zone_regime or show_zone_offsets # Permitting configuration of the template name. @@ -114,7 +145,7 @@ "end_month_list" : "\n".join(end_month_list), "regime_list" : "\n".join(regime_list), - "use_regime_label" : escape(_("Using local time")), + "use_regime_label" : escape(_("Using local time in...")), "show_end_date_label" : escape(_("Specify end date")), "hide_end_date_label" : escape(_("End event on same day")), @@ -123,7 +154,7 @@ "hide_times_label" : escape(_("No start and end times")), "show_offsets_label" : escape(_("Specify UTC offsets")), - "show_regime_label" : escape(_("Specify location")), + "show_regime_label" : escape(_("Use local time")), "hide_zone_label" : escape(_("Make times apply everywhere")), "start_label" : escape(_("Start date (day, month, year)")), @@ -148,8 +179,13 @@ "title_default" : escattr(form.get("title", [""])[0]), "description_label" : escape(_("Event description")), "description_default" : escattr(form.get("description", [""])[0]), + "location_label" : escape(_("Event location")), - "location_default" : escattr(form.get("location", [""])[0]), + "locations_list" : "\n".join(locations_list), + "show_location_label" : escattr(_("Specify a different location")), + "hide_location_label" : escattr(_("Choose a known location")), + "new_location" : escattr(form.get("new-location", [location])[0]), + "latitude_label" : escape(_("Latitude")), "latitude_default" : escattr(form.get("latitude", [""])[0]), "longitude_label" : escape(_("Longitude")), @@ -180,8 +216,52 @@ + ''' % d + + # Location options. + + html += ''' + + + ''' % d + + if not show_location: + html += ''' + + ''' % d + + else: + html += ''' + + ''' % d + + html += ''' + + ''' % d + + # Latitude and longitude. + + if show_location: + html += ''' + + + + + + + + + + ''' % d + + # Start date controls. + + html += ''' + @@ -246,8 +326,11 @@ elif show_zone_regime: html += ''' - - %(use_regime_label)s + +
+ ''' % d html += ''' @@ -272,16 +355,6 @@ UTC ''' % d - # Regime information displayed. - - elif show_zone_regime: - html += ''' - - - ''' % d - # Controls for removing times. html += ''' @@ -290,42 +363,27 @@ - ''' % d + + ''' % d # Time zone controls. if show_zones: - # Offset information displayed. - - if show_zone_offsets: - html += ''' - - ''' % d - - # Regime information displayed. - - elif show_zone_regime: - html += ''' - - ''' % d - # To remove zone information. html += ''' - - ''' % d + ''' % d # No time zone information shown. else: html += ''' - - - ''' % d + ''' % d html += ''' + ''' # Controls for adding times. @@ -349,24 +407,6 @@ - - - - - - - - - - - - - - - - - - diff -r 0d24005499ef -r f59288d38cad css/event-aggregator.css --- a/css/event-aggregator.css Sat Feb 18 16:37:58 2012 +0100 +++ b/css/event-aggregator.css Fri Mar 09 00:09:38 2012 +0100 @@ -6,7 +6,7 @@ ...before any rules. -Copyright (c) 2009, 2010, 2011 by Paul Boddie +Copyright (c) 2009, 2010, 2011, 2012 by Paul Boddie Licensed under the GNU GPL (v2 or later), see COPYING.txt for details. */ @@ -549,5 +549,11 @@ font-size: smaller; } +/* New event form. */ + +td.event-regime-selection { + vertical-align: top; +} + /* vim: tabstop=4 expandtab shiftwidth=4 */ diff -r 0d24005499ef -r f59288d38cad pages/HelpOnEventAggregatorNewEvent --- a/pages/HelpOnEventAggregatorNewEvent Sat Feb 18 16:37:58 2012 +0100 +++ b/pages/HelpOnEventAggregatorNewEvent Fri Mar 09 00:09:38 2012 +0100 @@ -10,17 +10,19 @@ Upon invoking the action, a form will be displayed requesting values for the following items: * The title or summary of the event; this will be used as the page name. + * The location of the event (optional). * The start date of the event. * A description of the event (optional). - * The location of the event (optional). * A canonical URL for the event (optional). Additional controls are available through a number of buttons: + * `Specify a different location` exposes a field where a potentially new or not previously known location can be specified. The latitude and longitude of this new location can also be specified if desired. * `Specify end date` exposes a field for the end date of the event (if different from the start date). * `Specify times` exposes fields for the start and end times of the event. - * `Specify location` exposes a field which links time information to a time "regime" observed in a particular place. - * `Specify UTC offsets` exposes fields which allow times to be associated with particular time zones. + * `Use local time` exposes a field which links time information to a time "regime" observed in a particular place. + * `Specify UTC offsets` exposes fields which allow times to be associated with particular time zones. Offsets can be written like, for example, `0200` or `+0200` for zones east of the prime meridian, and `-0200` for zones west of the prime meridian. + * `Make times apply everywhere` hides time zone-related fields, indicating that the time is to be considered local to the observer. * `Add topic` permits topic information to be specified. * `Show advanced options` permits advanced options to be inspected and changed. @@ -28,8 +30,8 @@ If a page already exists with a name identical to that provided as the event title, the form will prompt for an alternative title. If no end date is provided, the start and end dates will be identical in the newly created page. -{{{#!wiki caution -If no changes are made to the new page during editing and the editing process is cancelled, the new page will still exist. Event pages created in error should therefore be deleted manually. +{{{#!wiki tip +If editing of the new page is cancelled, no new page should be created. Thus, it should be safe to create an event using the form, inspect the page, and then decide whether or not the page should really be created for the event. }}} == Categories and Templates == diff -r 0d24005499ef -r f59288d38cad resource_pages/EventLocationsDict --- a/resource_pages/EventLocationsDict Sat Feb 18 16:37:58 2012 +0100 +++ b/resource_pages/EventLocationsDict Fri Mar 09 00:09:38 2012 +0100 @@ -1,29 +1,32 @@ -A list of location names mapping to their positions written as ` `, where northern latitudes are positive, southern latitudes are negative, western longitudes are negative, and eastern longitudes are positive. +A list of location names mapping to... -Latitudes and longitudes are thus written as `[+|-] [ : [ : ] ]` - in other words, a positive or negative number of degrees optionally followed by a colon and a number of minutes, optionally followed by a colon and a number of seconds. + 1. Their positions written as ` `, where northern latitudes are positive, southern latitudes are negative, western longitudes are negative, and eastern longitudes are positive. + 2. The time zone/regime applying in that location (optional), specified using a zone listed on the [[WikiPedia:List_of_tz_database_time_zones|list of zones found at Wikipedia]]. + +Latitudes and longitudes are thus written as `[+|-] [ : [ : ] ]` - in other words, a positive or negative number of degrees optionally followed by a colon and a number of minutes, optionally followed by a colon and a number of seconds. Spaces should be omitted between the elements of each value. - Oslo, Norway:: 59:56:58 10:45:23 - Reykjavík, Iceland:: 64:8 -21:56 - Tórshavn, Faroe Islands:: 62:0:42 -6:46:3 - Madrid, Spain:: 40:23 -3:43 - Paris, France:: 48:51:24 2:21:3 - Birmingham, United Kingdom:: 52:28:59 -1:53:37 - Brussels, Belgium:: 50:51:0 4:21:0 - Gothenburg, Sweden:: 57:42 11:58 - Moscow, Russia:: 55:45:06 37:37:04 - Helsinki, Finland:: 60:10:15 24:56:15 - Helsinki, FI:: 60:10:15 24:56:15 - Tampere, Finland:: 61:30 23:46 - Valkeakoski, Finland:: 61:16 24:02 - Mariehamn, Finland:: 60:06 19:56 - Akureyri, Iceland:: 65:41 -18:06 - Vienna, Austria:: 48:12:32 16:22:21 - Wien, Austria:: 48:12:32 16:22:21 - Graz, Austria:: 47:04:13 15:26:20 - Linz, Austria:: 48:18:11 14:17:26 - Azores, Portugal:: 37:44:28 -25:40:32 - Amsterdam, The Netherlands:: 52:22:23 4:53:32 + Oslo, Norway:: 59:56:58 10:45:23 Europe/Oslo + Reykjavík, Iceland:: 64:8 -21:56 Atlantic/Reykjavik + Tórshavn, Faroe Islands:: 62:0:42 -6:46:3 Atlantic/Faroe + Madrid, Spain:: 40:23 -3:43 Europe/Madrid + Paris, France:: 48:51:24 2:21:3 Europe/Paris + Birmingham, United Kingdom:: 52:28:59 -1:53:37 Europe/London + Brussels, Belgium:: 50:51:0 4:21:0 Europe/Brussels + Gothenburg, Sweden:: 57:42 11:58 Europe/Stockholm + Moscow, Russia:: 55:45:06 37:37:04 Europe/Moscow + Helsinki, Finland:: 60:10:15 24:56:15 Europe/Helsinki + Helsinki, FI:: 60:10:15 24:56:15 Europe/Helsinki + Tampere, Finland:: 61:30 23:46 Europe/Helsinki + Valkeakoski, Finland:: 61:16 24:02 Europe/Helsinki + Mariehamn, Finland:: 60:06 19:56 Europe/Helsinki + Akureyri, Iceland:: 65:41 -18:06 Atlantic/Reykjavik + Vienna, Austria:: 48:12:32 16:22:21 Europe/Vienna + Wien, Austria:: 48:12:32 16:22:21 Europe/Vienna + Graz, Austria:: 47:04:13 15:26:20 Europe/Vienna + Linz, Austria:: 48:18:11 14:17:26 Europe/Vienna + Azores, Portugal:: 37:44:28 -25:40:32 Atlantic/Azores + Amsterdam, The Netherlands:: 52:22:23 4:53:32 Europe/Amsterdam Jan Mayen, Norway:: 70:59 -8:32 - Berlin, Germany:: 52:30:2 13:23:56 + Berlin, Germany:: 52:30:2 13:23:56 Europe/Berlin Location details have been obtained from [[WikiPedia:|Wikipedia]].