1.1 --- a/imipweb/event.py Sat Oct 17 19:52:09 2015 +0200
1.2 +++ b/imipweb/event.py Sat Oct 17 23:09:07 2015 +0200
1.3 @@ -53,9 +53,6 @@
1.4 (None, "Not indicated"),
1.5 ]
1.6
1.7 - def can_change_object(self):
1.8 - return self.is_organiser() or self._is_request()
1.9 -
1.10 def can_remove_recurrence(self, recurrence):
1.11
1.12 """
1.13 @@ -63,8 +60,7 @@
1.14 without notification.
1.15 """
1.16
1.17 - return self.can_change_object() and \
1.18 - (self.can_edit_recurrence(recurrence) or not self.is_organiser()) and \
1.19 + return (self.can_edit_recurrence(recurrence) or not self.is_organiser()) and \
1.20 recurrence.origin != "RRULE"
1.21
1.22 def can_edit_recurrence(self, recurrence):
1.23 @@ -86,8 +82,7 @@
1.24 notification.
1.25 """
1.26
1.27 - return self.can_change_object() and \
1.28 - (self.can_edit_attendee(attendee) or attendee == self.user and self.is_organiser())
1.29 + return self.can_edit_attendee(attendee) or attendee == self.user and self.is_organiser()
1.30
1.31 def can_edit_attendee(self, attendee):
1.32
1.33 @@ -237,7 +232,7 @@
1.34 if name in "ATTENDEE":
1.35 rowspan = len(attendees) + 1
1.36 elif name == "DTEND":
1.37 - rowspan = self.can_change_object() and 2 or 1
1.38 + rowspan = 2
1.39 elif not items:
1.40 continue
1.41
1.42 @@ -281,7 +276,7 @@
1.43
1.44 # After the end datetime, show a control to add recurrences.
1.45
1.46 - if name == "DTEND" and self.can_change_object():
1.47 + if name == "DTEND":
1.48 page.tr()
1.49 page.td()
1.50 self.control("recur-add", "submit", "add", id="recur-add", class_="add")
1.51 @@ -321,15 +316,14 @@
1.52
1.53 # Allow more attendees to be specified.
1.54
1.55 - if self.can_change_object():
1.56 - if not first:
1.57 - page.tr()
1.58 + if not first:
1.59 + page.tr()
1.60
1.61 - page.td()
1.62 - self.control("add", "submit", "add", id="add", class_="add")
1.63 - page.label("Add attendee", for_="add", class_="add")
1.64 - page.td.close()
1.65 - page.tr.close()
1.66 + page.td()
1.67 + self.control("add", "submit", "add", id="add", class_="add")
1.68 + page.label("Add attendee", for_="add", class_="add")
1.69 + page.td.close()
1.70 + page.tr.close()
1.71
1.72 # Handle potentially many values of other kinds.
1.73
1.74 @@ -377,7 +371,7 @@
1.75
1.76 # Show a form control as organiser for new attendees.
1.77
1.78 - if self.can_change_object() and self.can_edit_attendee(attendee_uri):
1.79 + if self.can_edit_attendee(attendee_uri):
1.80 self.control("attendee", "value", attendee, size="40")
1.81 else:
1.82 self.control("attendee", "hidden", attendee)
1.83 @@ -450,34 +444,10 @@
1.84
1.85 page.p("This event occurs on the following occasions within the next %d days:" % self.get_window_size())
1.86
1.87 - # Show each recurrence in a separate table if editable.
1.88 -
1.89 - if self.can_change_object() and recurrences:
1.90 -
1.91 - for index, period in enumerate(recurrences):
1.92 - self.show_recurrence(index, period, self.recurrenceid, recurrenceids, errors)
1.93 -
1.94 - # Otherwise, use a compact single table.
1.95 + # Show each recurrence in a separate table.
1.96
1.97 - else:
1.98 - page.table(cellspacing=5, cellpadding=5, class_="recurrence")
1.99 - page.caption("Occurrences")
1.100 - page.thead()
1.101 - page.tr()
1.102 - page.th("Start", class_="objectheading start")
1.103 - page.th("End", class_="objectheading end")
1.104 - page.tr.close()
1.105 - page.thead.close()
1.106 - page.tbody()
1.107 -
1.108 - for index, period in enumerate(recurrences):
1.109 - page.tr()
1.110 - self.show_recurrence_label(index, period, self.recurrenceid, recurrenceids, True)
1.111 - self.show_recurrence_label(index, period, self.recurrenceid, recurrenceids, False)
1.112 - page.tr.close()
1.113 -
1.114 - page.tbody.close()
1.115 - page.table.close()
1.116 + for index, period in enumerate(recurrences):
1.117 + self.show_recurrence(index, period, self.recurrenceid, recurrenceids, errors)
1.118
1.119 def show_recurrence(self, index, period, recurrenceid, recurrenceids, errors=None):
1.120
1.121 @@ -842,49 +812,45 @@
1.122
1.123 if reply or create or cancel or save:
1.124
1.125 - # Update principal event details if organiser.
1.126 + # Update time periods (main and recurring).
1.127
1.128 - if self.can_change_object():
1.129 -
1.130 - # Update time periods (main and recurring).
1.131 + try:
1.132 + period = self.handle_main_period()
1.133 + except PeriodError, exc:
1.134 + return exc.args
1.135
1.136 - try:
1.137 - period = self.handle_main_period()
1.138 - except PeriodError, exc:
1.139 - return exc.args
1.140 + try:
1.141 + periods = self.handle_recurrence_periods()
1.142 + except PeriodError, exc:
1.143 + return exc.args
1.144
1.145 - try:
1.146 - periods = self.handle_recurrence_periods()
1.147 - except PeriodError, exc:
1.148 - return exc.args
1.149 + # Set the periods in the object, first obtaining removed and
1.150 + # modified period information.
1.151
1.152 - # Set the periods in the object, first obtaining removed and
1.153 - # modified period information.
1.154 -
1.155 - to_unschedule, to_exclude = self.get_removed_periods(periods)
1.156 + to_unschedule, to_exclude = self.get_removed_periods(periods)
1.157 + periods = set(periods)
1.158
1.159 - changed = self.obj.set_period(period) or changed
1.160 - changed = self.obj.set_periods(periods) or changed
1.161 - changed = self.obj.update_exceptions(to_exclude) or changed
1.162 - changed = self.revert_cancellations(periods) or changed
1.163 + changed = self.obj.set_period(period) or changed
1.164 + changed = self.obj.set_periods(periods) or changed
1.165 + changed = self.obj.update_exceptions(to_exclude) or changed
1.166 + changed = self.revert_cancellations(periods) or changed
1.167
1.168 - # Organiser-only changes...
1.169 + # Organiser-only changes...
1.170
1.171 - if self.is_organiser():
1.172 + if self.is_organiser():
1.173
1.174 - # Update summary.
1.175 + # Update summary.
1.176
1.177 - if args.has_key("summary"):
1.178 - self.obj["SUMMARY"] = [(args["summary"][0], {})]
1.179 + if args.has_key("summary"):
1.180 + self.obj["SUMMARY"] = [(args["summary"][0], {})]
1.181
1.182 - # Obtain any new participants and those to be removed.
1.183 + # Obtain any new participants and those to be removed.
1.184
1.185 - if self.can_change_object():
1.186 - attendees = self.get_attendees_from_page()
1.187 - removed = [attendees[int(i)] for i in args.get("remove", [])]
1.188 - added, to_cancel = self.update_attendees(attendees, removed)
1.189 - single_user = not attendees or attendees == [self.user]
1.190 - changed = added or changed
1.191 + attendees = self.get_attendees_from_page()
1.192 + removed = [attendees[int(i)] for i in args.get("remove", [])]
1.193 + added, to_cancel = self.update_attendees(attendees, removed)
1.194 + single_user = not attendees or attendees == [self.user]
1.195 + changed = added or changed
1.196
1.197 # Update attendee participation for the current user.
1.198
1.199 @@ -996,7 +962,7 @@
1.200
1.201 "Return period details for the recurrences specified for an event."
1.202
1.203 - return set([p.as_event_period(i) for i, p in enumerate(self.get_recurrences_from_page())])
1.204 + return [p.as_event_period(i) for i, p in enumerate(self.get_recurrences_from_page())]
1.205
1.206 # Access to form-originating object information.
1.207
1.208 @@ -1210,7 +1176,7 @@
1.209 on whether editing has begun or whether the object has just been loaded.
1.210 """
1.211
1.212 - if self.is_initial_load() or not self.can_change_object():
1.213 + if self.is_initial_load():
1.214 return self.get_stored_main_period()
1.215 else:
1.216 return self.get_main_period_from_page()
1.217 @@ -1222,7 +1188,7 @@
1.218 details where no editing is in progress, using form data otherwise.
1.219 """
1.220
1.221 - if self.is_initial_load() or not self.can_change_object():
1.222 + if self.is_initial_load():
1.223 return self.get_stored_recurrences()
1.224 else:
1.225 return self.get_recurrences_from_page()
1.226 @@ -1231,7 +1197,7 @@
1.227
1.228 "Return an updated collection of recurrences for the current object."
1.229
1.230 - if self.is_initial_load() or not self.can_change_object():
1.231 + if self.is_initial_load():
1.232 return self.get_stored_recurrences()
1.233 else:
1.234 return self.update_recurrences_from_page()
1.235 @@ -1244,7 +1210,7 @@
1.236 form.
1.237 """
1.238
1.239 - if self.is_initial_load() or not self.can_change_object():
1.240 + if self.is_initial_load():
1.241 return self.get_stored_attendees()
1.242 else:
1.243 return self.get_attendees_from_page()
1.244 @@ -1253,7 +1219,7 @@
1.245
1.246 "Return an updated collection of attendees for the current object."
1.247
1.248 - if self.is_initial_load() or not self.can_change_object():
1.249 + if self.is_initial_load():
1.250 return self.get_stored_attendees()
1.251 else:
1.252 return self.update_attendees_from_page()
2.1 --- a/imipweb/resource.py Sat Oct 17 19:52:09 2015 +0200
2.2 +++ b/imipweb/resource.py Sat Oct 17 23:09:07 2015 +0200
2.3 @@ -611,39 +611,29 @@
2.4
2.5 page = self.page
2.6
2.7 - # Show controls for editing as organiser.
2.8 -
2.9 - if self.can_change_object():
2.10 - page.td(class_="objectvalue dt%s" % (show_start and "start" or "end"))
2.11 + # Show controls for editing.
2.12
2.13 - if show_start:
2.14 - page.div(class_="dt enabled")
2.15 - self.date_controls("dtstart", formdate)
2.16 - page.br()
2.17 - page.label("Specify times", for_="dttimes-enable", class_="time disabled enable")
2.18 - page.label("Specify dates only", for_="dttimes-enable", class_="time enabled disable")
2.19 - page.div.close()
2.20 + page.td(class_="objectvalue dt%s" % (show_start and "start" or "end"))
2.21
2.22 - else:
2.23 - page.div(class_="dt disabled")
2.24 - page.label("Specify end date", for_="dtend-enable", class_="enable")
2.25 - page.div.close()
2.26 - page.div(class_="dt enabled")
2.27 - self.date_controls("dtend", formdate)
2.28 - page.br()
2.29 - page.label("End on same day", for_="dtend-enable", class_="disable")
2.30 - page.div.close()
2.31 -
2.32 - page.td.close()
2.33 -
2.34 - # Show a label as attendee.
2.35 + if show_start:
2.36 + page.div(class_="dt enabled")
2.37 + self.date_controls("dtstart", formdate)
2.38 + page.br()
2.39 + page.label("Specify times", for_="dttimes-enable", class_="time disabled enable")
2.40 + page.label("Specify dates only", for_="dttimes-enable", class_="time enabled disable")
2.41 + page.div.close()
2.42
2.43 else:
2.44 - dt = formdate.as_datetime()
2.45 - if dt:
2.46 - page.td(self.format_datetime(dt, "full"))
2.47 - else:
2.48 - page.td("(Unrecognised date)")
2.49 + page.div(class_="dt disabled")
2.50 + page.label("Specify end date", for_="dtend-enable", class_="enable")
2.51 + page.div.close()
2.52 + page.div(class_="dt enabled")
2.53 + self.date_controls("dtend", formdate)
2.54 + page.br()
2.55 + page.label("End on same day", for_="dtend-enable", class_="disable")
2.56 + page.div.close()
2.57 +
2.58 + page.td.close()
2.59
2.60 def show_recurrence_controls(self, index, period, recurrenceid, recurrenceids, show_start):
2.61
2.62 @@ -673,9 +663,9 @@
2.63
2.64 period = form_period_from_period(period)
2.65
2.66 - # Show controls for editing as organiser.
2.67 + # Show controls for editing.
2.68
2.69 - if self.can_change_object() and not replaced:
2.70 + if not replaced:
2.71 error = errors and (show_start and ("dtstart", index) in errors or not show_start and ("dtend", index) in errors) and " error" or ""
2.72 page.td(class_="objectvalue dt%s%s" % (show_start and "start" or "end", error))
2.73