1.1 --- a/imipweb/event.py Mon Apr 06 00:38:24 2015 +0200
1.2 +++ b/imipweb/event.py Mon Apr 06 00:39:51 2015 +0200
1.3 @@ -182,16 +182,25 @@
1.4 def handle_all_period_controls(self):
1.5
1.6 """
1.7 - Handle datetime controls for a particular period, where 'index' may be
1.8 - used to indicate a recurring period, or the main start and end datetimes
1.9 - are handled.
1.10 + Handle datetime controls for all periods, including the main period for
1.11 + an event as well as any recurring periods.
1.12 """
1.13
1.14 - args = self.env.get_args()
1.15 + period, errors = self.handle_main_period_controls()
1.16 + if errors:
1.17 + return None, errors
1.18 +
1.19 + periods, errors = self.handle_recurrence_period_controls()
1.20 + if errors:
1.21 + return None, errors
1.22
1.23 - periods = []
1.24 + return ([period] + periods), None
1.25 +
1.26 + def handle_main_period_controls(self):
1.27
1.28 - # Get the main period details.
1.29 + "Return period details for the main start/end period in an event."
1.30 +
1.31 + args = self.env.get_args()
1.32
1.33 dtend_enabled = args.get("dtend-control", [None])[0]
1.34 dttimes_enabled = args.get("dttimes-control", [None])[0]
1.35 @@ -202,16 +211,22 @@
1.36
1.37 if errors:
1.38 return None, errors
1.39 + else:
1.40 + return period, errors
1.41
1.42 - periods.append(period)
1.43 + def handle_recurrence_period_controls(self):
1.44
1.45 - # Get the recurring period details.
1.46 + "Return period details for the recurrences specified for an event."
1.47 +
1.48 + args = self.env.get_args()
1.49
1.50 all_dtend_enabled = args.get("dtend-control-recur", [])
1.51 all_dttimes_enabled = args.get("dttimes-control-recur", [])
1.52 all_start_values = self.get_date_control_values("dtstart-recur", multiple=True)
1.53 all_end_values = self.get_date_control_values("dtend-recur", multiple=True, tzid_name="dtstart-recur")
1.54
1.55 + periods = []
1.56 +
1.57 for index, (start_values, end_values, dtend_enabled, dttimes_enabled) in \
1.58 enumerate(map(None, all_start_values, all_end_values, all_dtend_enabled, all_dttimes_enabled)):
1.59
1.60 @@ -467,17 +482,15 @@
1.61 if args.has_key("add"):
1.62 attendees.append("")
1.63
1.64 - # Only actually remove attendees if the event is unsent or if it is the
1.65 - # current user being removed.
1.66 + # Only actually remove attendees if the event is unsent, if the attendee
1.67 + # is new, or if it is the current user being removed.
1.68
1.69 if args.has_key("remove"):
1.70 for i in args["remove"]:
1.71 attendee = attendees[int(i)]
1.72 existing = attendee in existing_attendees
1.73
1.74 - if attendee in attendees and \
1.75 - (not existing or sequence is None or attendee == self.user):
1.76 -
1.77 + if not existing or sequence is None or attendee == self.user:
1.78 attendees.remove(attendee)
1.79
1.80 return attendees
1.81 @@ -806,12 +819,12 @@
1.82 page.tr()
1.83 error = errors and ("dtstart", index) in errors and " error" or ""
1.84 page.th("Start", class_="objectheading start%s" % error)
1.85 - self.show_recurrence_controls(obj, index, p.start, p.end, p.origin, recurrenceid, recurrenceids, True)
1.86 + self.show_recurrence_controls(obj, index, p, recurrenceid, recurrenceids, True)
1.87 page.tr.close()
1.88 page.tr()
1.89 error = errors and ("dtend", index) in errors and " error" or ""
1.90 page.th("End", class_="objectheading end%s" % error)
1.91 - self.show_recurrence_controls(obj, index, p.start, p.end, p.origin, recurrenceid, recurrenceids, False)
1.92 + self.show_recurrence_controls(obj, index, p, recurrenceid, recurrenceids, False)
1.93 page.tr.close()
1.94 page.tbody.close()
1.95 page.table.close()
1.96 @@ -836,8 +849,8 @@
1.97
1.98 for index, p in enumerate(self.is_organiser(obj) and periods[1:] or periods):
1.99 page.tr()
1.100 - self.show_recurrence_controls(obj, index, p.start, p.end, p.origin, recurrenceid, recurrenceids, True)
1.101 - self.show_recurrence_controls(obj, index, p.start, p.end, p.origin, recurrenceid, recurrenceids, False)
1.102 + self.show_recurrence_controls(obj, index, p, recurrenceid, recurrenceids, True)
1.103 + self.show_recurrence_controls(obj, index, p, recurrenceid, recurrenceids, False)
1.104 page.tr.close()
1.105
1.106 page.tbody.close()
1.107 @@ -1032,14 +1045,14 @@
1.108 else:
1.109 page.td(self.format_datetime(dt, "full"))
1.110
1.111 - def show_recurrence_controls(self, obj, index, start, end, origin, recurrenceid, recurrenceids, show_start):
1.112 + def show_recurrence_controls(self, obj, index, period, recurrenceid, recurrenceids, show_start):
1.113
1.114 """
1.115 Show datetime details from the given 'obj' for the recurrence having the
1.116 - given 'index', with the recurrence period described by the datetimes
1.117 - 'start' and 'end', indicating the 'origin' of the period from the event
1.118 - details, employing any 'recurrenceid' and 'recurrenceids' for the object
1.119 - to configure the displayed information.
1.120 + given 'index', with the recurrence period described by 'period',
1.121 + indicating a start, end and origin of the period from the event details,
1.122 + employing any 'recurrenceid' and 'recurrenceids' for the object to
1.123 + configure the displayed information.
1.124
1.125 If 'show_start' is set to a true value, the start details will be shown;
1.126 otherwise, the end details will be shown.
1.127 @@ -1048,14 +1061,15 @@
1.128 page = self.page
1.129 sn = self._suffixed_name
1.130 ssn = self._simple_suffixed_name
1.131 + p = period
1.132
1.133 # Change end dates to refer to the actual dates, not the iCalendar
1.134 # "next day" dates.
1.135
1.136 - if not isinstance(end, datetime):
1.137 - end -= timedelta(1)
1.138 + if not isinstance(p.end, datetime):
1.139 + p.end -= timedelta(1)
1.140
1.141 - start_utc = format_datetime(to_timezone(start, "UTC"))
1.142 + start_utc = format_datetime(to_timezone(p.start, "UTC"))
1.143 replaced = recurrenceids and start_utc in recurrenceids and "replaced" or ""
1.144 css = " ".join([
1.145 replaced,
1.146 @@ -1064,12 +1078,12 @@
1.147
1.148 # Show controls for editing as organiser.
1.149
1.150 - if self.is_organiser(obj) and not replaced and origin != "RRULE":
1.151 + if self.is_organiser(obj) and not replaced and p.origin != "RRULE":
1.152 page.td(class_="objectvalue dt%s" % (show_start and "start" or "end"))
1.153
1.154 if show_start:
1.155 page.div(class_="dt enabled")
1.156 - self._show_date_controls(ssn("dtstart", "recur", index), start, index=index)
1.157 + self._show_date_controls(ssn("dtstart", "recur", index), p.start, p.start_attr.get("TZID"), index=index)
1.158 page.br()
1.159 page.label("Specify times", for_=sn("dttimes-enable", index), class_="time disabled enable")
1.160 page.label("Specify dates only", for_=sn("dttimes-enable", index), class_="time enabled disable")
1.161 @@ -1080,7 +1094,7 @@
1.162 page.label("Specify end date", for_=sn("dtend-enable", index), class_="enable")
1.163 page.div.close()
1.164 page.div(class_="dt enabled")
1.165 - self._show_date_controls(ssn("dtend", "recur", index), end, index=index, show_tzid=False)
1.166 + self._show_date_controls(ssn("dtend", "recur", index), p.end, index=index, show_tzid=False)
1.167 page.br()
1.168 page.label("End on same day", for_=sn("dtend-enable", index), class_="disable")
1.169 page.div.close()
1.170 @@ -1090,7 +1104,7 @@
1.171 # Show label as attendee.
1.172
1.173 else:
1.174 - page.td(self.format_datetime(show_start and start or end, "long"), class_=css)
1.175 + page.td(self.format_datetime(show_start and p.start or p.end, "long"), class_=css)
1.176
1.177 # Full page output methods.
1.178