1.1 --- a/actions/EventAggregatorNewEvent.py Sat Feb 18 16:37:58 2012 +0100
1.2 +++ b/actions/EventAggregatorNewEvent.py Fri Mar 09 00:09:38 2012 +0100
1.3 @@ -39,13 +39,7 @@
1.4 show_advanced = form.get("advanced") and not form.get("basic")
1.5 show_end_date = form.get("end-day") and not form.get("hide-end-date") or form.get("show-end-date")
1.6 show_times = (form.get("start-hour") or form.get("end-hour")) and not form.get("hide-times") or form.get("show-times")
1.7 -
1.8 - show_zone_regime = form.get("regime") and not form.get("show-offsets") and \
1.9 - not form.get("hide-zone") or form.get("show-regime")
1.10 - show_zone_offsets = form.get("start-offset") and not form.get("show-regime") and \
1.11 - not form.get("hide-zone") or form.get("show-offsets")
1.12 -
1.13 - show_zones = show_zone_regime or show_zone_offsets
1.14 + show_location = form.get("show-location") or form.get("new-location") and not form.get("hide-location")
1.15
1.16 # Prepare the category list.
1.17
1.18 @@ -84,19 +78,56 @@
1.19 start_month_list, end_month_list = self.get_month_lists(default_as_current=1)
1.20 start_year_default, end_year_default = self.get_year_defaults(default_as_current=1)
1.21
1.22 + # Initialise the locations list.
1.23 +
1.24 + locations_page = getLocationsPage(request)
1.25 + locations = getWikiDict(locations_page, request)
1.26 +
1.27 + locations_list = []
1.28 + locations_list.append('<option value=""></option>')
1.29 +
1.30 + location = (form.get("location") or form.get("new-location") or [""])[0]
1.31 +
1.32 + # Prepare the locations list, selecting the specified location.
1.33 +
1.34 + if locations:
1.35 + locations_list += self.get_option_list(location, locations) or []
1.36 +
1.37 + locations_list.sort()
1.38 +
1.39 + # Initialise the time regime from the location.
1.40 +
1.41 + regime = form.get("regime", [None])[0]
1.42 +
1.43 + if not regime:
1.44 + regime = Location(location, locations).getTimeRegime()
1.45 +
1.46 # Initialise regime lists.
1.47
1.48 regime_list = []
1.49 - regime_list.append('<option value=""></option>')
1.50 -
1.51 - regime = form.get("regime", [None])[0]
1.52 + regime_list.append('<option value="">%s</option>' % escape(_("<The event location (if known)>")))
1.53
1.54 # Prepare regime lists, selecting specified regimes.
1.55
1.56 if pytz is not None:
1.57 - for pytz_regime in pytz.common_timezones:
1.58 - selected = self._get_selected(pytz_regime, regime)
1.59 - regime_list.append('<option value="%s" %s>%s</option>' % (escattr(pytz_regime), selected, escape(pytz_regime)))
1.60 + regime_list += self.get_option_list(regime, pytz.common_timezones)
1.61 +
1.62 + # Show time zone-related information depending on various fields.
1.63 +
1.64 + show_zone_regime = (
1.65 + (form.get("regime") or regime) # have a regime value
1.66 + and not form.get("show-offsets") # are not switching to offsets
1.67 + and not form.get("hide-zone") # are not removing zone information
1.68 + or form.get("show-regime") # are switching to a regime
1.69 + )
1.70 + show_zone_offsets = (
1.71 + form.get("start-offset") # have an offset
1.72 + and not form.get("show-regime") # are not switching to a regime
1.73 + and not form.get("hide-zone") # are not removing zone information
1.74 + or form.get("show-offsets") # are switching to offsets
1.75 + )
1.76 +
1.77 + show_zones = show_zone_regime or show_zone_offsets
1.78
1.79 # Permitting configuration of the template name.
1.80
1.81 @@ -114,7 +145,7 @@
1.82 "end_month_list" : "\n".join(end_month_list),
1.83
1.84 "regime_list" : "\n".join(regime_list),
1.85 - "use_regime_label" : escape(_("Using local time")),
1.86 + "use_regime_label" : escape(_("Using local time in...")),
1.87
1.88 "show_end_date_label" : escape(_("Specify end date")),
1.89 "hide_end_date_label" : escape(_("End event on same day")),
1.90 @@ -123,7 +154,7 @@
1.91 "hide_times_label" : escape(_("No start and end times")),
1.92
1.93 "show_offsets_label" : escape(_("Specify UTC offsets")),
1.94 - "show_regime_label" : escape(_("Specify location")),
1.95 + "show_regime_label" : escape(_("Use local time")),
1.96 "hide_zone_label" : escape(_("Make times apply everywhere")),
1.97
1.98 "start_label" : escape(_("Start date (day, month, year)")),
1.99 @@ -148,8 +179,13 @@
1.100 "title_default" : escattr(form.get("title", [""])[0]),
1.101 "description_label" : escape(_("Event description")),
1.102 "description_default" : escattr(form.get("description", [""])[0]),
1.103 +
1.104 "location_label" : escape(_("Event location")),
1.105 - "location_default" : escattr(form.get("location", [""])[0]),
1.106 + "locations_list" : "\n".join(locations_list),
1.107 + "show_location_label" : escattr(_("Specify a different location")),
1.108 + "hide_location_label" : escattr(_("Choose a known location")),
1.109 + "new_location" : escattr(form.get("new-location", [location])[0]),
1.110 +
1.111 "latitude_label" : escape(_("Latitude")),
1.112 "latitude_default" : escattr(form.get("latitude", [""])[0]),
1.113 "longitude_label" : escape(_("Longitude")),
1.114 @@ -180,8 +216,52 @@
1.115 <td colspan="2">
1.116 <input name="title" type="text" size="40" value="%(title_default)s" />
1.117 </td>
1.118 + </tr>''' % d
1.119 +
1.120 + # Location options.
1.121 +
1.122 + html += '''
1.123 + <tr>
1.124 + <td class="label"><label>%(location_label)s</label></td>
1.125 + <td colspan="2">''' % d
1.126 +
1.127 + if not show_location:
1.128 + html += '''
1.129 + <select name="location">
1.130 + %(locations_list)s
1.131 + </select>
1.132 + <input name="show-location" type="submit" value="%(show_location_label)s" />''' % d
1.133 +
1.134 + else:
1.135 + html += '''
1.136 + <input name="new-location" type="text" size="30" value="%(new_location)s" />
1.137 + <input name="hide-location" type="submit" value="%(hide_location_label)s" />''' % d
1.138 +
1.139 + html += '''
1.140 + </td>
1.141 + </tr>''' % d
1.142 +
1.143 + # Latitude and longitude.
1.144 +
1.145 + if show_location:
1.146 + html += '''
1.147 + <tr>
1.148 + <td class="label"><label>%(latitude_label)s</label></td>
1.149 + <td colspan="2">
1.150 + <input name="latitude" type="text" size="40" value="%(latitude_default)s" />
1.151 + </td>
1.152 </tr>
1.153 <tr>
1.154 + <td class="label"><label>%(longitude_label)s</label></td>
1.155 + <td colspan="2">
1.156 + <input name="longitude" type="text" size="40" value="%(longitude_default)s" />
1.157 + </td>
1.158 + </tr>''' % d
1.159 +
1.160 + # Start date controls.
1.161 +
1.162 + html += '''
1.163 + <tr>
1.164 <td class="label"><label>%(start_label)s</label></td>
1.165 <td colspan="2" style="white-space: nowrap">
1.166 <input name="start-day" type="text" value="%(start_day_default)s" size="2" />
1.167 @@ -246,8 +326,11 @@
1.168
1.169 elif show_zone_regime:
1.170 html += '''
1.171 - <td>
1.172 - %(use_regime_label)s
1.173 + <td class="event-regime-selection" rowspan="2">
1.174 + <label>%(use_regime_label)s</label><br/>
1.175 + <select name="regime">
1.176 + %(regime_list)s
1.177 + </select>
1.178 </td>''' % d
1.179
1.180 html += '''
1.181 @@ -272,16 +355,6 @@
1.182 UTC <input name="end-offset" type="text" value="%(end_offset_default)s" size="6" maxlength="6" />
1.183 </td>''' % d
1.184
1.185 - # Regime information displayed.
1.186 -
1.187 - elif show_zone_regime:
1.188 - html += '''
1.189 - <td>
1.190 - <select name="regime">
1.191 - %(regime_list)s
1.192 - </select>
1.193 - </td>''' % d
1.194 -
1.195 # Controls for removing times.
1.196
1.197 html += '''
1.198 @@ -290,42 +363,27 @@
1.199 <td class="label">
1.200 <input name="hide-times" type="submit" value="%(hide_times_label)s" />
1.201 </td>
1.202 - <td></td>''' % d
1.203 + <td></td>
1.204 + <td>''' % d
1.205
1.206 # Time zone controls.
1.207
1.208 if show_zones:
1.209
1.210 - # Offset information displayed.
1.211 -
1.212 - if show_zone_offsets:
1.213 - html += '''
1.214 - <td>
1.215 - <input name="show-regime" type="submit" value="%(show_regime_label)s" />''' % d
1.216 -
1.217 - # Regime information displayed.
1.218 -
1.219 - elif show_zone_regime:
1.220 - html += '''
1.221 - <td>
1.222 - <input name="show-offsets" type="submit" value="%(show_offsets_label)s" />''' % d
1.223 -
1.224 # To remove zone information.
1.225
1.226 html += '''
1.227 - <input name="hide-zone" type="submit" value="%(hide_zone_label)s" />
1.228 - </td>''' % d
1.229 + <input name="hide-zone" type="submit" value="%(hide_zone_label)s" />''' % d
1.230
1.231 # No time zone information shown.
1.232
1.233 else:
1.234 html += '''
1.235 - <td>
1.236 <input name="show-regime" type="submit" value="%(show_regime_label)s" />
1.237 - <input name="show-offsets" type="submit" value="%(show_offsets_label)s" />
1.238 - </td>''' % d
1.239 + <input name="show-offsets" type="submit" value="%(show_offsets_label)s" />''' % d
1.240
1.241 html += '''
1.242 + </td>
1.243 </tr>'''
1.244
1.245 # Controls for adding times.
1.246 @@ -349,24 +407,6 @@
1.247 </td>
1.248 </tr>
1.249 <tr>
1.250 - <td class="label"><label>%(location_label)s</label></td>
1.251 - <td colspan="2">
1.252 - <input name="location" type="text" size="40" value="%(location_default)s" />
1.253 - </td>
1.254 - </tr>
1.255 - <tr>
1.256 - <td class="label"><label>%(latitude_label)s</label></td>
1.257 - <td colspan="2">
1.258 - <input name="latitude" type="text" size="40" value="%(latitude_default)s" />
1.259 - </td>
1.260 - </tr>
1.261 - <tr>
1.262 - <td class="label"><label>%(longitude_label)s</label></td>
1.263 - <td colspan="2">
1.264 - <input name="longitude" type="text" size="40" value="%(longitude_default)s" />
1.265 - </td>
1.266 - </tr>
1.267 - <tr>
1.268 <td class="label"><label>%(link_label)s</label></td>
1.269 <td colspan="2">
1.270 <input name="link" type="text" size="40" value="%(link_default)s" />