5.1 --- a/imipweb/event.py Sat Sep 19 01:08:17 2015 +0200
5.2 +++ b/imipweb/event.py Sat Sep 19 17:23:16 2015 +0200
5.3 @@ -29,15 +29,15 @@
5.4 event_period_from_period, form_period_from_period, \
5.5 FormDate, FormPeriod, PeriodError
5.6 from imipweb.client import ManagerClient
5.7 -from imipweb.resource import Resource
5.8 +from imipweb.resource import ResourceClientForObject
5.9 import pytz
5.10
5.11 -class EventPage(Resource):
5.12 +class EventPage(ResourceClientForObject):
5.13
5.14 "A request handler for the event page."
5.15
5.16 def __init__(self, resource=None, messenger=None):
5.17 - Resource.__init__(self, resource)
5.18 + ResourceClientForObject.__init__(self, resource)
5.19 self.messenger = messenger or Messenger()
5.20
5.21 # Various property values and labels.
5.22 @@ -61,37 +61,25 @@
5.23
5.24 # Access to stored object information.
5.25
5.26 - def is_organiser(self, obj):
5.27 - return get_uri(obj.get_value("ORGANIZER")) == self.user
5.28 -
5.29 - def get_stored_attendees(self, obj):
5.30 - return uri_values(obj.get_values("ATTENDEE") or [])
5.31 + def is_organiser(self):
5.32 + return get_uri(self.obj.get_value("ORGANIZER")) == self.user
5.33
5.34 - def get_stored_main_period(self, obj):
5.35 -
5.36 - """
5.37 - Return the main event period for the given 'obj'.
5.38 - """
5.39 + def get_stored_attendees(self):
5.40 + return uri_values(self.obj.get_values("ATTENDEE") or [])
5.41
5.42 - dtstart, dtstart_attr = obj.get_datetime_item("DTSTART")
5.43 + def get_stored_main_period(self):
5.44
5.45 - if obj.has_key("DTEND"):
5.46 - dtend, dtend_attr = obj.get_datetime_item("DTEND")
5.47 - elif obj.has_key("DURATION"):
5.48 - duration = obj.get_duration("DURATION")
5.49 - dtend = dtstart + duration
5.50 - dtend_attr = dtstart_attr
5.51 - else:
5.52 - dtend, dtend_attr = dtstart, dtstart_attr
5.53 + "Return the main event period for the current object."
5.54
5.55 + (dtstart, dtstart_attr), (dtend, dtend_attr) = self.obj.get_main_period_items(self.get_tzid())
5.56 return EventPeriod(dtstart, dtend, self.get_tzid(), None, dtstart_attr, dtend_attr)
5.57
5.58 - def get_stored_recurrences(self, obj):
5.59 + def get_stored_recurrences(self):
5.60
5.61 - "Return recurrences computed using the given 'obj'."
5.62 + "Return recurrences computed using the current object."
5.63
5.64 recurrences = []
5.65 - for period in self.get_periods(obj):
5.66 + for period in self.get_periods(self.obj):
5.67 if period.origin != "DTSTART":
5.68 recurrences.append(period)
5.69 return recurrences
5.70 @@ -104,19 +92,16 @@
5.71
5.72 return not self.env.get_args().has_key("editing")
5.73
5.74 - def handle_request(self, obj):
5.75 + def handle_request(self):
5.76
5.77 """
5.78 - Handle actions involving the given 'obj' as an object's representation,
5.79 - returning an error if one occurred, or None if the request was
5.80 - successfully handled.
5.81 + Handle actions involving the current object, returning an error if one
5.82 + occurred, or None if the request was successfully handled.
5.83 """
5.84
5.85 # Handle a submitted form.
5.86
5.87 args = self.env.get_args()
5.88 - uid = obj.get_uid()
5.89 - recurrenceid = obj.get_recurrenceid()
5.90
5.91 # Get the possible actions.
5.92
5.93 @@ -146,7 +131,7 @@
5.94
5.95 # Update principal event details if organiser.
5.96
5.97 - if self.is_organiser(obj):
5.98 + if self.is_organiser():
5.99
5.100 # Update time periods (main and recurring).
5.101
5.102 @@ -165,25 +150,25 @@
5.103
5.104 to_unschedule = self.get_removed_periods()
5.105
5.106 - obj.set_period(period)
5.107 - obj.set_periods(periods)
5.108 + self.obj.set_period(period)
5.109 + self.obj.set_periods(periods)
5.110
5.111 # Update summary.
5.112
5.113 if args.has_key("summary"):
5.114 - obj["SUMMARY"] = [(args["summary"][0], {})]
5.115 + self.obj["SUMMARY"] = [(args["summary"][0], {})]
5.116
5.117 # Obtain any participants and those to be removed.
5.118
5.119 attendees = self.get_attendees_from_page()
5.120 removed = [attendees[int(i)] for i in args.get("remove", [])]
5.121 - to_cancel = self.update_attendees(obj, attendees, removed)
5.122 + to_cancel = self.update_attendees(self.obj, attendees, removed)
5.123 single_user = not attendees or attendees == [self.user]
5.124
5.125 # Update attendee participation for the current user.
5.126
5.127 if args.has_key("partstat"):
5.128 - self.update_participation(obj, args["partstat"][0])
5.129 + self.update_participation(self.obj, args["partstat"][0])
5.130
5.131 # Process any action.
5.132
5.133 @@ -194,35 +179,35 @@
5.134
5.135 if reply or invite or cancel:
5.136
5.137 - client = ManagerClient(obj, self.user, self.messenger)
5.138 + client = ManagerClient(self.obj, self.user, self.messenger)
5.139
5.140 # Process the object and remove it from the list of requests.
5.141
5.142 if reply and client.process_received_request():
5.143 - self.remove_request(uid, recurrenceid)
5.144 + self.remove_request(self.uid, self.recurrenceid)
5.145
5.146 - elif self.is_organiser(obj) and (invite or cancel):
5.147 + elif self.is_organiser() and (invite or cancel):
5.148
5.149 # Invitation, uninvitation and unscheduling...
5.150
5.151 if client.process_created_request(
5.152 invite and "REQUEST" or "CANCEL", to_cancel, to_unschedule):
5.153
5.154 - self.remove_request(uid, recurrenceid)
5.155 + self.remove_request(self.uid, self.recurrenceid)
5.156
5.157 # Save single user events.
5.158
5.159 elif save:
5.160 - self.store.set_event(self.user, uid, recurrenceid, node=obj.to_node())
5.161 - self.update_freebusy(uid, recurrenceid, obj)
5.162 - self.remove_request(uid, recurrenceid)
5.163 + self.store.set_event(self.user, self.uid, self.recurrenceid, node=self.obj.to_node())
5.164 + self.update_event_in_freebusy()
5.165 + self.remove_request(self.uid, self.recurrenceid)
5.166
5.167 # Remove the request and the object.
5.168
5.169 elif discard:
5.170 - self.remove_from_freebusy(uid, recurrenceid)
5.171 - self.remove_event(uid, recurrenceid)
5.172 - self.remove_request(uid, recurrenceid)
5.173 + self.remove_event_from_freebusy()
5.174 + self.remove_event(self.uid, self.recurrenceid)
5.175 + self.remove_request(self.uid, self.recurrenceid)
5.176
5.177 else:
5.178 handled = False
5.179 @@ -284,15 +269,15 @@
5.180
5.181 return all_values
5.182
5.183 - def get_current_main_period(self, obj):
5.184 + def get_current_main_period(self):
5.185
5.186 """
5.187 - Return the currently active main period for 'obj' depending on whether
5.188 - editing has begun or whether the object has just been loaded.
5.189 + Return the currently active main period for the current object depending
5.190 + on whether editing has begun or whether the object has just been loaded.
5.191 """
5.192
5.193 - if self.is_initial_load() or not self.is_organiser(obj):
5.194 - return self.get_stored_main_period(obj)
5.195 + if self.is_initial_load() or not self.is_organiser():
5.196 + return self.get_stored_main_period()
5.197 else:
5.198 return self.get_main_period()
5.199
5.200 @@ -309,15 +294,15 @@
5.201
5.202 return FormPeriod(start, end, dtend_enabled, dttimes_enabled, self.get_tzid())
5.203
5.204 - def get_current_recurrences(self, obj):
5.205 + def get_current_recurrences(self):
5.206
5.207 """
5.208 - Return recurrences for 'obj' using the original object where no editing
5.209 - is in progress, using form data otherwise.
5.210 + Return recurrences for the current object using the original object
5.211 + details where no editing is in progress, using form data otherwise.
5.212 """
5.213
5.214 - if self.is_initial_load() or not self.is_organiser(obj):
5.215 - return self.get_stored_recurrences(obj)
5.216 + if self.is_initial_load() or not self.is_organiser():
5.217 + return self.get_stored_recurrences()
5.218 else:
5.219 return self.get_recurrences()
5.220
5.221 @@ -355,15 +340,16 @@
5.222 to_unschedule.append(periods[int(i)])
5.223 return to_unschedule
5.224
5.225 - def get_current_attendees(self, obj):
5.226 + def get_current_attendees(self):
5.227
5.228 """
5.229 - Return attendees for 'obj' depending on whether the object is being
5.230 - edited.
5.231 + Return attendees for the current object depending on whether the object
5.232 + has been edited or instead provides such information from its stored
5.233 + form.
5.234 """
5.235
5.236 - if self.is_initial_load() or not self.is_organiser(obj):
5.237 - return self.get_stored_attendees(obj)
5.238 + if self.is_initial_load() or not self.is_organiser():
5.239 + return self.get_stored_attendees()
5.240 else:
5.241 return self.get_attendees_from_page()
5.242
5.243 @@ -390,14 +376,14 @@
5.244
5.245 return ordered_attendees
5.246
5.247 - def update_attendees_from_page(self, obj):
5.248 + def update_attendees_from_page(self):
5.249
5.250 "Add or remove attendees. This does not affect the stored object."
5.251
5.252 args = self.env.get_args()
5.253
5.254 attendees = self.get_attendees_from_page()
5.255 - existing_attendees = self.get_stored_attendees(obj)
5.256 + existing_attendees = self.get_stored_attendees()
5.257
5.258 if args.has_key("add"):
5.259 attendees.append("")
5.260 @@ -414,27 +400,27 @@
5.261
5.262 existing = attendee in existing_attendees
5.263
5.264 - if not existing or not obj.is_shared() or attendee == self.user:
5.265 + if not existing or not self.obj.is_shared() or attendee == self.user:
5.266 attendees.remove(attendee)
5.267
5.268 return attendees
5.269
5.270 # Page fragment methods.
5.271
5.272 - def show_request_controls(self, obj):
5.273 + def show_request_controls(self):
5.274
5.275 - "Show form controls for a request concerning 'obj'."
5.276 + "Show form controls for a request."
5.277
5.278 page = self.page
5.279 args = self.env.get_args()
5.280
5.281 - attendees = self.get_current_attendees(obj)
5.282 + attendees = self.get_current_attendees()
5.283 is_attendee = self.user in attendees
5.284 - is_request = self._have_request(obj.get_uid(), obj.get_recurrenceid())
5.285 + is_request = self._have_request(self.uid, self.recurrenceid)
5.286
5.287 # Show appropriate options depending on the role of the user.
5.288
5.289 - if is_attendee and not self.is_organiser(obj):
5.290 + if is_attendee and not self.is_organiser():
5.291 page.p("An action is required for this request:")
5.292
5.293 page.p()
5.294 @@ -445,14 +431,14 @@
5.295 self._control("ignore", "submit", "Do nothing for now")
5.296 page.p.close()
5.297
5.298 - if self.is_organiser(obj):
5.299 + if self.is_organiser():
5.300 page.p("As organiser, you can perform the following:")
5.301
5.302 page.p()
5.303 - self._control("create", "submit", not obj.is_shared() and "Create event" or "Update event")
5.304 + self._control("create", "submit", not self.obj.is_shared() and "Create event" or "Update event")
5.305 page.add(" ")
5.306
5.307 - if obj.is_shared() and not is_request:
5.308 + if self.obj.is_shared() and not is_request:
5.309 self._control("cancel", "submit", "Cancel event")
5.310 else:
5.311 self._control("discard", "submit", "Discard event")
5.312 @@ -461,12 +447,11 @@
5.313 self._control("save", "submit", "Save without sending")
5.314 page.p.close()
5.315
5.316 - def show_object_on_page(self, obj, errors=None):
5.317 + def show_object_on_page(self, errors=None):
5.318
5.319 """
5.320 - Show the calendar object with the representation 'obj' on the current
5.321 - page. If 'errors' is given, show a suitable message for the different
5.322 - errors provided.
5.323 + Show the calendar object on the current page. If 'errors' is given, show
5.324 + a suitable message for the different errors provided.
5.325 """
5.326
5.327 page = self.page
5.328 @@ -476,24 +461,22 @@
5.329
5.330 self._control("editing", "hidden", "true")
5.331
5.332 - uid = obj.get_uid()
5.333 args = self.env.get_args()
5.334
5.335 # Obtain basic event information, generating any necessary editing controls.
5.336
5.337 - if self.is_initial_load() or not self.is_organiser(obj):
5.338 - attendees = self.get_stored_attendees(obj)
5.339 + if self.is_initial_load() or not self.is_organiser():
5.340 + attendees = self.get_stored_attendees()
5.341 else:
5.342 - attendees = self.update_attendees_from_page(obj)
5.343 + attendees = self.update_attendees_from_page()
5.344
5.345 - p = self.get_current_main_period(obj)
5.346 + p = self.get_current_main_period()
5.347 self.show_object_datetime_controls(p)
5.348
5.349 # Obtain any separate recurrences for this event.
5.350
5.351 - recurrenceid = obj.get_recurrenceid()
5.352 - recurrenceids = self._get_active_recurrences(uid)
5.353 - replaced = not recurrenceid and p.is_replaced(recurrenceids)
5.354 + recurrenceids = self._get_active_recurrences(self.uid)
5.355 + replaced = not self.recurrenceid and p.is_replaced(recurrenceids)
5.356
5.357 # Provide a summary of the object.
5.358
5.359 @@ -508,7 +491,7 @@
5.360 for name, label in self.property_items:
5.361 field = name.lower()
5.362
5.363 - items = obj.get_items(name) or []
5.364 + items = self.obj.get_items(name) or []
5.365 rowspan = len(items)
5.366
5.367 if name == "ATTENDEE":
5.368 @@ -532,11 +515,11 @@
5.369 # basis of any potential datetime specified if dt-control is
5.370 # set.
5.371
5.372 - self.show_datetime_controls(obj, is_start and p.get_form_start() or p.get_form_end(), is_start)
5.373 + self.show_datetime_controls(is_start and p.get_form_start() or p.get_form_end(), is_start)
5.374
5.375 elif name == "DTSTART":
5.376 page.td(class_="objectvalue %s replaced" % field, rowspan=2)
5.377 - page.a("First occurrence replaced by a separate event", href=self.link_to(uid, replaced))
5.378 + page.a("First occurrence replaced by a separate event", href=self.link_to(self.uid, replaced))
5.379 page.td.close()
5.380
5.381 page.tr.close()
5.382 @@ -544,10 +527,10 @@
5.383 # Handle the summary specially.
5.384
5.385 elif name == "SUMMARY":
5.386 - value = args.get("summary", [obj.get_value(name)])[0]
5.387 + value = args.get("summary", [self.obj.get_value(name)])[0]
5.388
5.389 page.td(class_="objectvalue summary")
5.390 - if self.is_organiser(obj):
5.391 + if self.is_organiser():
5.392 self._control("summary", "text", value, size=80)
5.393 else:
5.394 page.add(value)
5.395 @@ -568,12 +551,12 @@
5.396
5.397 # Obtain details of attendees to supply attributes.
5.398
5.399 - self.show_attendee(obj, i, value, attendee_map.get(value))
5.400 + self.show_attendee(i, value, attendee_map.get(value))
5.401 page.tr.close()
5.402
5.403 # Allow more attendees to be specified.
5.404
5.405 - if self.is_organiser(obj):
5.406 + if self.is_organiser():
5.407 if not first:
5.408 page.tr()
5.409
5.410 @@ -602,17 +585,17 @@
5.411 page.tbody.close()
5.412 page.table.close()
5.413
5.414 - self.show_recurrences(obj, errors)
5.415 - self.show_conflicting_events(obj)
5.416 - self.show_request_controls(obj)
5.417 + self.show_recurrences(errors)
5.418 + self.show_conflicting_events()
5.419 + self.show_request_controls()
5.420
5.421 page.form.close()
5.422
5.423 - def show_attendee(self, obj, i, attendee, attendee_attr):
5.424 + def show_attendee(self, i, attendee, attendee_attr):
5.425
5.426 """
5.427 - For the given object 'obj', show the attendee in position 'i' with the
5.428 - given 'attendee' value, having 'attendee_attr' as any stored attributes.
5.429 + For the current object, show the attendee in position 'i' with the given
5.430 + 'attendee' value, having 'attendee_attr' as any stored attributes.
5.431 """
5.432
5.433 page = self.page
5.434 @@ -625,7 +608,7 @@
5.435
5.436 # Show a form control as organiser for new attendees.
5.437
5.438 - if self.is_organiser(obj) and (not existing or not obj.is_shared()):
5.439 + if self.is_organiser() and (not existing or not self.obj.is_shared()):
5.440 self._control("attendee", "value", attendee, size="40")
5.441 else:
5.442 self._control("attendee", "hidden", attendee)
5.443 @@ -641,7 +624,7 @@
5.444 # button in order to refresh the page and show a control for
5.445 # the current user, if indicated.
5.446
5.447 - elif self.is_organiser(obj) and not existing:
5.448 + elif self.is_organiser() and not existing:
5.449 self._control("partstat-refresh", "submit", "refresh", id="partstat-%d" % i, class_="refresh")
5.450 page.label(dict(self.partstat_items).get(partstat, ""), for_="partstat-%s" % i, class_="partstat")
5.451 else:
5.452 @@ -649,11 +632,11 @@
5.453
5.454 # Permit organisers to remove attendees.
5.455
5.456 - if self.is_organiser(obj):
5.457 + if self.is_organiser():
5.458
5.459 # Permit the removal of newly-added attendees.
5.460
5.461 - remove_type = (not existing or not obj.is_shared() or attendee == self.user) and "submit" or "checkbox"
5.462 + remove_type = (not existing or not self.obj.is_shared() or attendee == self.user) and "submit" or "checkbox"
5.463 self._control("remove", remove_type, str(i), str(i) in args.get("remove", []), id="remove-%d" % i, class_="remove")
5.464
5.465 page.label("Remove", for_="remove-%d" % i, class_="remove")
5.466 @@ -664,48 +647,44 @@
5.467
5.468 page.td.close()
5.469
5.470 - def show_recurrences(self, obj, errors=None):
5.471 + def show_recurrences(self, errors=None):
5.472
5.473 """
5.474 - Show recurrences for the object having the given representation 'obj'.
5.475 - If 'errors' is given, show a suitable message for the different errors
5.476 - provided.
5.477 + Show recurrences for the current object. If 'errors' is given, show a
5.478 + suitable message for the different errors provided.
5.479 """
5.480
5.481 page = self.page
5.482
5.483 # Obtain any parent object if this object is a specific recurrence.
5.484
5.485 - uid = obj.get_uid()
5.486 - recurrenceid = obj.get_recurrenceid()
5.487 -
5.488 - if recurrenceid:
5.489 - parent = self.get_stored_object(uid, None)
5.490 + if self.recurrenceid:
5.491 + parent = self.get_stored_object(self.uid, None)
5.492 if not parent:
5.493 return
5.494
5.495 page.p()
5.496 - page.a("This event modifies a recurring event.", href=self.link_to(uid))
5.497 + page.a("This event modifies a recurring event.", href=self.link_to(self.uid))
5.498 page.p.close()
5.499
5.500 # Obtain the periods associated with the event.
5.501 # NOTE: Add a control to add recurrences here.
5.502
5.503 - recurrences = self.get_current_recurrences(obj)
5.504 + recurrences = self.get_current_recurrences()
5.505
5.506 if len(recurrences) < 1:
5.507 return
5.508
5.509 - recurrenceids = self._get_recurrences(uid)
5.510 + recurrenceids = self._get_recurrences(self.uid)
5.511
5.512 page.p("This event occurs on the following occasions within the next %d days:" % self.get_window_size())
5.513
5.514 # Show each recurrence in a separate table if editable.
5.515
5.516 - if self.is_organiser(obj) and recurrences:
5.517 + if self.is_organiser() and recurrences:
5.518
5.519 for index, period in enumerate(recurrences):
5.520 - self.show_recurrence(obj, index, period, recurrenceid, recurrenceids, errors)
5.521 + self.show_recurrence(index, period, self.recurrenceid, recurrenceids, errors)
5.522
5.523 # Otherwise, use a compact single table.
5.524
5.525 @@ -722,21 +701,21 @@
5.526
5.527 for index, period in enumerate(recurrences):
5.528 page.tr()
5.529 - self.show_recurrence_label(period, recurrenceid, recurrenceids, True)
5.530 - self.show_recurrence_label(period, recurrenceid, recurrenceids, False)
5.531 + self.show_recurrence_label(period, self.recurrenceid, recurrenceids, True)
5.532 + self.show_recurrence_label(period, self.recurrenceid, recurrenceids, False)
5.533 page.tr.close()
5.534
5.535 page.tbody.close()
5.536 page.table.close()
5.537
5.538 - def show_recurrence(self, obj, index, period, recurrenceid, recurrenceids, errors=None):
5.539 + def show_recurrence(self, index, period, recurrenceid, recurrenceids, errors=None):
5.540
5.541 """
5.542 - Show recurrence controls for a recurrence provided by 'obj' with the
5.543 - given 'index' position in the list of periods, the given 'period'
5.544 - details, where a 'recurrenceid' indicates any specific recurrence, and
5.545 - where 'recurrenceids' indicates all known additional recurrences for the
5.546 - object.
5.547 + Show recurrence controls for a recurrence provided by the current object
5.548 + with the given 'index' position in the list of periods, the given
5.549 + 'period' details, where a 'recurrenceid' indicates any specific
5.550 + recurrence, and where 'recurrenceids' indicates all known additional
5.551 + recurrences for the object.
5.552
5.553 If 'errors' is given, show a suitable message for the different errors
5.554 provided.
5.555 @@ -761,12 +740,12 @@
5.556 page.tr()
5.557 error = errors and ("dtstart", index) in errors and " error" or ""
5.558 page.th("Start", class_="objectheading start%s" % error)
5.559 - self.show_recurrence_controls(obj, index, period, recurrenceid, recurrenceids, True)
5.560 + self.show_recurrence_controls(index, period, recurrenceid, recurrenceids, True)
5.561 page.tr.close()
5.562 page.tr()
5.563 error = errors and ("dtend", index) in errors and " error" or ""
5.564 page.th("End", class_="objectheading end%s" % error)
5.565 - self.show_recurrence_controls(obj, index, period, recurrenceid, recurrenceids, False)
5.566 + self.show_recurrence_controls(index, period, recurrenceid, recurrenceids, False)
5.567 page.tr.close()
5.568
5.569 # Permit the removal of recurrences.
5.570 @@ -776,7 +755,7 @@
5.571 page.th("")
5.572 page.td()
5.573
5.574 - remove_type = not obj.is_shared() or not period.origin and "submit" or "checkbox"
5.575 + remove_type = not self.obj.is_shared() or not period.origin and "submit" or "checkbox"
5.576 self._control("recur-remove", remove_type, str(index),
5.577 str(index) in args.get("recur-remove", []),
5.578 id="recur-remove-%d" % index, class_="remove")
5.579 @@ -795,28 +774,24 @@
5.580
5.581 page.div.close()
5.582
5.583 - def show_conflicting_events(self, obj):
5.584 + def show_conflicting_events(self):
5.585
5.586 - """
5.587 - Show conflicting events for the object having the representation 'obj'.
5.588 - """
5.589 + "Show conflicting events for the current object."
5.590
5.591 page = self.page
5.592 - uid = obj.get_uid()
5.593 - recurrenceid = obj.get_recurrenceid()
5.594 - recurrenceids = self._get_active_recurrences(uid)
5.595 + recurrenceids = self._get_active_recurrences(self.uid)
5.596
5.597 # Obtain the user's timezone.
5.598
5.599 tzid = self.get_tzid()
5.600 - periods = self.get_periods(obj)
5.601 + periods = self.get_periods(self.obj)
5.602
5.603 # Indicate whether there are conflicting events.
5.604
5.605 conflicts = []
5.606 - attendee_map = uri_dict(obj.get_value_map("ATTENDEE"))
5.607 + attendee_map = uri_dict(self.obj.get_value_map("ATTENDEE"))
5.608
5.609 - for participant in self.get_current_attendees(obj):
5.610 + for participant in self.get_current_attendees():
5.611 if participant == self.user:
5.612 freebusy = self.store.get_freebusy(participant)
5.613 else:
5.614 @@ -827,21 +802,21 @@
5.615
5.616 # Obtain any time zone details from the suggested event.
5.617
5.618 - _dtstart, attr = obj.get_item("DTSTART")
5.619 + _dtstart, attr = self.obj.get_item("DTSTART")
5.620 tzid = attr.get("TZID", tzid)
5.621
5.622 # Show any conflicts with periods of actual attendance.
5.623
5.624 participant_attr = attendee_map.get(participant)
5.625 partstat = participant_attr and participant_attr.get("PARTSTAT")
5.626 - recurrences = obj.get_recurrence_start_points(recurrenceids, tzid)
5.627 + recurrences = self.obj.get_recurrence_start_points(recurrenceids, tzid)
5.628
5.629 for p in have_conflict(freebusy, periods, True):
5.630 - if not recurrenceid and p.is_replaced(recurrences):
5.631 + if not self.recurrenceid and p.is_replaced(recurrences):
5.632 continue
5.633
5.634 if ( # Unidentified or different event
5.635 - (p.uid != uid or recurrenceid and p.recurrenceid and p.recurrenceid != recurrenceid) and
5.636 + (p.uid != self.uid or self.recurrenceid and p.recurrenceid and p.recurrenceid != self.recurrenceid) and
5.637 # Different period or unclear participation with the same period
5.638 (p not in periods or not partstat in ("ACCEPTED", "TENTATIVE")) and
5.639 # Participant not limited to organising
5.640 @@ -945,19 +920,19 @@
5.641 id=_id("dttimes-enable", index)
5.642 )
5.643
5.644 - def show_datetime_controls(self, obj, formdate, show_start):
5.645 + def show_datetime_controls(self, formdate, show_start):
5.646
5.647 """
5.648 - Show datetime details from the given 'obj' for the 'formdate', showing
5.649 - start details if 'show_start' is set to a true value. Details will
5.650 - appear as controls for organisers and labels for attendees.
5.651 + Show datetime details from the current object for the 'formdate',
5.652 + showing start details if 'show_start' is set to a true value. Details
5.653 + will appear as controls for organisers and labels for attendees.
5.654 """
5.655
5.656 page = self.page
5.657
5.658 # Show controls for editing as organiser.
5.659
5.660 - if self.is_organiser(obj):
5.661 + if self.is_organiser():
5.662 page.td(class_="objectvalue dt%s" % (show_start and "start" or "end"))
5.663
5.664 if show_start:
5.665 @@ -989,11 +964,11 @@
5.666 else:
5.667 page.td("(Unrecognised date)")
5.668
5.669 - def show_recurrence_controls(self, obj, index, period, recurrenceid, recurrenceids, show_start):
5.670 + def show_recurrence_controls(self, index, period, recurrenceid, recurrenceids, show_start):
5.671
5.672 """
5.673 - Show datetime details from the given 'obj' for the recurrence having the
5.674 - given 'index', with the recurrence period described by 'period',
5.675 + Show datetime details from the current object for the recurrence having
5.676 + the given 'index', with the recurrence period described by 'period',
5.677 indicating a start, end and origin of the period from the event details,
5.678 employing any 'recurrenceid' and 'recurrenceids' for the object to
5.679 configure the displayed information.
5.680 @@ -1011,7 +986,7 @@
5.681
5.682 # Show controls for editing as organiser.
5.683
5.684 - if self.is_organiser(obj) and not replaced:
5.685 + if self.is_organiser() and not replaced:
5.686 page.td(class_="objectvalue dt%s" % (show_start and "start" or "end"))
5.687
5.688 read_only = period.origin == "RRULE"
5.689 @@ -1084,17 +1059,18 @@
5.690
5.691 uid, recurrenceid, section = self.get_identifiers(path_info)
5.692 obj = self.get_stored_object(uid, recurrenceid, section)
5.693 + self.set_object(obj)
5.694
5.695 if not obj:
5.696 return False
5.697
5.698 - errors = self.handle_request(obj)
5.699 + errors = self.handle_request()
5.700
5.701 if not errors:
5.702 return True
5.703
5.704 self.new_page(title="Event")
5.705 - self.show_object_on_page(obj, errors)
5.706 + self.show_object_on_page(errors)
5.707
5.708 return True
5.709