1.1 --- a/imipweb/event.py Sat Sep 19 01:08:17 2015 +0200
1.2 +++ b/imipweb/event.py Sat Sep 19 17:23:16 2015 +0200
1.3 @@ -29,15 +29,15 @@
1.4 event_period_from_period, form_period_from_period, \
1.5 FormDate, FormPeriod, PeriodError
1.6 from imipweb.client import ManagerClient
1.7 -from imipweb.resource import Resource
1.8 +from imipweb.resource import ResourceClientForObject
1.9 import pytz
1.10
1.11 -class EventPage(Resource):
1.12 +class EventPage(ResourceClientForObject):
1.13
1.14 "A request handler for the event page."
1.15
1.16 def __init__(self, resource=None, messenger=None):
1.17 - Resource.__init__(self, resource)
1.18 + ResourceClientForObject.__init__(self, resource)
1.19 self.messenger = messenger or Messenger()
1.20
1.21 # Various property values and labels.
1.22 @@ -61,37 +61,25 @@
1.23
1.24 # Access to stored object information.
1.25
1.26 - def is_organiser(self, obj):
1.27 - return get_uri(obj.get_value("ORGANIZER")) == self.user
1.28 -
1.29 - def get_stored_attendees(self, obj):
1.30 - return uri_values(obj.get_values("ATTENDEE") or [])
1.31 + def is_organiser(self):
1.32 + return get_uri(self.obj.get_value("ORGANIZER")) == self.user
1.33
1.34 - def get_stored_main_period(self, obj):
1.35 -
1.36 - """
1.37 - Return the main event period for the given 'obj'.
1.38 - """
1.39 + def get_stored_attendees(self):
1.40 + return uri_values(self.obj.get_values("ATTENDEE") or [])
1.41
1.42 - dtstart, dtstart_attr = obj.get_datetime_item("DTSTART")
1.43 + def get_stored_main_period(self):
1.44
1.45 - if obj.has_key("DTEND"):
1.46 - dtend, dtend_attr = obj.get_datetime_item("DTEND")
1.47 - elif obj.has_key("DURATION"):
1.48 - duration = obj.get_duration("DURATION")
1.49 - dtend = dtstart + duration
1.50 - dtend_attr = dtstart_attr
1.51 - else:
1.52 - dtend, dtend_attr = dtstart, dtstart_attr
1.53 + "Return the main event period for the current object."
1.54
1.55 + (dtstart, dtstart_attr), (dtend, dtend_attr) = self.obj.get_main_period_items(self.get_tzid())
1.56 return EventPeriod(dtstart, dtend, self.get_tzid(), None, dtstart_attr, dtend_attr)
1.57
1.58 - def get_stored_recurrences(self, obj):
1.59 + def get_stored_recurrences(self):
1.60
1.61 - "Return recurrences computed using the given 'obj'."
1.62 + "Return recurrences computed using the current object."
1.63
1.64 recurrences = []
1.65 - for period in self.get_periods(obj):
1.66 + for period in self.get_periods(self.obj):
1.67 if period.origin != "DTSTART":
1.68 recurrences.append(period)
1.69 return recurrences
1.70 @@ -104,19 +92,16 @@
1.71
1.72 return not self.env.get_args().has_key("editing")
1.73
1.74 - def handle_request(self, obj):
1.75 + def handle_request(self):
1.76
1.77 """
1.78 - Handle actions involving the given 'obj' as an object's representation,
1.79 - returning an error if one occurred, or None if the request was
1.80 - successfully handled.
1.81 + Handle actions involving the current object, returning an error if one
1.82 + occurred, or None if the request was successfully handled.
1.83 """
1.84
1.85 # Handle a submitted form.
1.86
1.87 args = self.env.get_args()
1.88 - uid = obj.get_uid()
1.89 - recurrenceid = obj.get_recurrenceid()
1.90
1.91 # Get the possible actions.
1.92
1.93 @@ -146,7 +131,7 @@
1.94
1.95 # Update principal event details if organiser.
1.96
1.97 - if self.is_organiser(obj):
1.98 + if self.is_organiser():
1.99
1.100 # Update time periods (main and recurring).
1.101
1.102 @@ -165,25 +150,25 @@
1.103
1.104 to_unschedule = self.get_removed_periods()
1.105
1.106 - obj.set_period(period)
1.107 - obj.set_periods(periods)
1.108 + self.obj.set_period(period)
1.109 + self.obj.set_periods(periods)
1.110
1.111 # Update summary.
1.112
1.113 if args.has_key("summary"):
1.114 - obj["SUMMARY"] = [(args["summary"][0], {})]
1.115 + self.obj["SUMMARY"] = [(args["summary"][0], {})]
1.116
1.117 # Obtain any participants and those to be removed.
1.118
1.119 attendees = self.get_attendees_from_page()
1.120 removed = [attendees[int(i)] for i in args.get("remove", [])]
1.121 - to_cancel = self.update_attendees(obj, attendees, removed)
1.122 + to_cancel = self.update_attendees(self.obj, attendees, removed)
1.123 single_user = not attendees or attendees == [self.user]
1.124
1.125 # Update attendee participation for the current user.
1.126
1.127 if args.has_key("partstat"):
1.128 - self.update_participation(obj, args["partstat"][0])
1.129 + self.update_participation(self.obj, args["partstat"][0])
1.130
1.131 # Process any action.
1.132
1.133 @@ -194,35 +179,35 @@
1.134
1.135 if reply or invite or cancel:
1.136
1.137 - client = ManagerClient(obj, self.user, self.messenger)
1.138 + client = ManagerClient(self.obj, self.user, self.messenger)
1.139
1.140 # Process the object and remove it from the list of requests.
1.141
1.142 if reply and client.process_received_request():
1.143 - self.remove_request(uid, recurrenceid)
1.144 + self.remove_request(self.uid, self.recurrenceid)
1.145
1.146 - elif self.is_organiser(obj) and (invite or cancel):
1.147 + elif self.is_organiser() and (invite or cancel):
1.148
1.149 # Invitation, uninvitation and unscheduling...
1.150
1.151 if client.process_created_request(
1.152 invite and "REQUEST" or "CANCEL", to_cancel, to_unschedule):
1.153
1.154 - self.remove_request(uid, recurrenceid)
1.155 + self.remove_request(self.uid, self.recurrenceid)
1.156
1.157 # Save single user events.
1.158
1.159 elif save:
1.160 - self.store.set_event(self.user, uid, recurrenceid, node=obj.to_node())
1.161 - self.update_freebusy(uid, recurrenceid, obj)
1.162 - self.remove_request(uid, recurrenceid)
1.163 + self.store.set_event(self.user, self.uid, self.recurrenceid, node=self.obj.to_node())
1.164 + self.update_event_in_freebusy()
1.165 + self.remove_request(self.uid, self.recurrenceid)
1.166
1.167 # Remove the request and the object.
1.168
1.169 elif discard:
1.170 - self.remove_from_freebusy(uid, recurrenceid)
1.171 - self.remove_event(uid, recurrenceid)
1.172 - self.remove_request(uid, recurrenceid)
1.173 + self.remove_event_from_freebusy()
1.174 + self.remove_event(self.uid, self.recurrenceid)
1.175 + self.remove_request(self.uid, self.recurrenceid)
1.176
1.177 else:
1.178 handled = False
1.179 @@ -284,15 +269,15 @@
1.180
1.181 return all_values
1.182
1.183 - def get_current_main_period(self, obj):
1.184 + def get_current_main_period(self):
1.185
1.186 """
1.187 - Return the currently active main period for 'obj' depending on whether
1.188 - editing has begun or whether the object has just been loaded.
1.189 + Return the currently active main period for the current object depending
1.190 + on whether editing has begun or whether the object has just been loaded.
1.191 """
1.192
1.193 - if self.is_initial_load() or not self.is_organiser(obj):
1.194 - return self.get_stored_main_period(obj)
1.195 + if self.is_initial_load() or not self.is_organiser():
1.196 + return self.get_stored_main_period()
1.197 else:
1.198 return self.get_main_period()
1.199
1.200 @@ -309,15 +294,15 @@
1.201
1.202 return FormPeriod(start, end, dtend_enabled, dttimes_enabled, self.get_tzid())
1.203
1.204 - def get_current_recurrences(self, obj):
1.205 + def get_current_recurrences(self):
1.206
1.207 """
1.208 - Return recurrences for 'obj' using the original object where no editing
1.209 - is in progress, using form data otherwise.
1.210 + Return recurrences for the current object using the original object
1.211 + details where no editing is in progress, using form data otherwise.
1.212 """
1.213
1.214 - if self.is_initial_load() or not self.is_organiser(obj):
1.215 - return self.get_stored_recurrences(obj)
1.216 + if self.is_initial_load() or not self.is_organiser():
1.217 + return self.get_stored_recurrences()
1.218 else:
1.219 return self.get_recurrences()
1.220
1.221 @@ -355,15 +340,16 @@
1.222 to_unschedule.append(periods[int(i)])
1.223 return to_unschedule
1.224
1.225 - def get_current_attendees(self, obj):
1.226 + def get_current_attendees(self):
1.227
1.228 """
1.229 - Return attendees for 'obj' depending on whether the object is being
1.230 - edited.
1.231 + Return attendees for the current object depending on whether the object
1.232 + has been edited or instead provides such information from its stored
1.233 + form.
1.234 """
1.235
1.236 - if self.is_initial_load() or not self.is_organiser(obj):
1.237 - return self.get_stored_attendees(obj)
1.238 + if self.is_initial_load() or not self.is_organiser():
1.239 + return self.get_stored_attendees()
1.240 else:
1.241 return self.get_attendees_from_page()
1.242
1.243 @@ -390,14 +376,14 @@
1.244
1.245 return ordered_attendees
1.246
1.247 - def update_attendees_from_page(self, obj):
1.248 + def update_attendees_from_page(self):
1.249
1.250 "Add or remove attendees. This does not affect the stored object."
1.251
1.252 args = self.env.get_args()
1.253
1.254 attendees = self.get_attendees_from_page()
1.255 - existing_attendees = self.get_stored_attendees(obj)
1.256 + existing_attendees = self.get_stored_attendees()
1.257
1.258 if args.has_key("add"):
1.259 attendees.append("")
1.260 @@ -414,27 +400,27 @@
1.261
1.262 existing = attendee in existing_attendees
1.263
1.264 - if not existing or not obj.is_shared() or attendee == self.user:
1.265 + if not existing or not self.obj.is_shared() or attendee == self.user:
1.266 attendees.remove(attendee)
1.267
1.268 return attendees
1.269
1.270 # Page fragment methods.
1.271
1.272 - def show_request_controls(self, obj):
1.273 + def show_request_controls(self):
1.274
1.275 - "Show form controls for a request concerning 'obj'."
1.276 + "Show form controls for a request."
1.277
1.278 page = self.page
1.279 args = self.env.get_args()
1.280
1.281 - attendees = self.get_current_attendees(obj)
1.282 + attendees = self.get_current_attendees()
1.283 is_attendee = self.user in attendees
1.284 - is_request = self._have_request(obj.get_uid(), obj.get_recurrenceid())
1.285 + is_request = self._have_request(self.uid, self.recurrenceid)
1.286
1.287 # Show appropriate options depending on the role of the user.
1.288
1.289 - if is_attendee and not self.is_organiser(obj):
1.290 + if is_attendee and not self.is_organiser():
1.291 page.p("An action is required for this request:")
1.292
1.293 page.p()
1.294 @@ -445,14 +431,14 @@
1.295 self._control("ignore", "submit", "Do nothing for now")
1.296 page.p.close()
1.297
1.298 - if self.is_organiser(obj):
1.299 + if self.is_organiser():
1.300 page.p("As organiser, you can perform the following:")
1.301
1.302 page.p()
1.303 - self._control("create", "submit", not obj.is_shared() and "Create event" or "Update event")
1.304 + self._control("create", "submit", not self.obj.is_shared() and "Create event" or "Update event")
1.305 page.add(" ")
1.306
1.307 - if obj.is_shared() and not is_request:
1.308 + if self.obj.is_shared() and not is_request:
1.309 self._control("cancel", "submit", "Cancel event")
1.310 else:
1.311 self._control("discard", "submit", "Discard event")
1.312 @@ -461,12 +447,11 @@
1.313 self._control("save", "submit", "Save without sending")
1.314 page.p.close()
1.315
1.316 - def show_object_on_page(self, obj, errors=None):
1.317 + def show_object_on_page(self, errors=None):
1.318
1.319 """
1.320 - Show the calendar object with the representation 'obj' on the current
1.321 - page. If 'errors' is given, show a suitable message for the different
1.322 - errors provided.
1.323 + Show the calendar object on the current page. If 'errors' is given, show
1.324 + a suitable message for the different errors provided.
1.325 """
1.326
1.327 page = self.page
1.328 @@ -476,24 +461,22 @@
1.329
1.330 self._control("editing", "hidden", "true")
1.331
1.332 - uid = obj.get_uid()
1.333 args = self.env.get_args()
1.334
1.335 # Obtain basic event information, generating any necessary editing controls.
1.336
1.337 - if self.is_initial_load() or not self.is_organiser(obj):
1.338 - attendees = self.get_stored_attendees(obj)
1.339 + if self.is_initial_load() or not self.is_organiser():
1.340 + attendees = self.get_stored_attendees()
1.341 else:
1.342 - attendees = self.update_attendees_from_page(obj)
1.343 + attendees = self.update_attendees_from_page()
1.344
1.345 - p = self.get_current_main_period(obj)
1.346 + p = self.get_current_main_period()
1.347 self.show_object_datetime_controls(p)
1.348
1.349 # Obtain any separate recurrences for this event.
1.350
1.351 - recurrenceid = obj.get_recurrenceid()
1.352 - recurrenceids = self._get_active_recurrences(uid)
1.353 - replaced = not recurrenceid and p.is_replaced(recurrenceids)
1.354 + recurrenceids = self._get_active_recurrences(self.uid)
1.355 + replaced = not self.recurrenceid and p.is_replaced(recurrenceids)
1.356
1.357 # Provide a summary of the object.
1.358
1.359 @@ -508,7 +491,7 @@
1.360 for name, label in self.property_items:
1.361 field = name.lower()
1.362
1.363 - items = obj.get_items(name) or []
1.364 + items = self.obj.get_items(name) or []
1.365 rowspan = len(items)
1.366
1.367 if name == "ATTENDEE":
1.368 @@ -532,11 +515,11 @@
1.369 # basis of any potential datetime specified if dt-control is
1.370 # set.
1.371
1.372 - self.show_datetime_controls(obj, is_start and p.get_form_start() or p.get_form_end(), is_start)
1.373 + self.show_datetime_controls(is_start and p.get_form_start() or p.get_form_end(), is_start)
1.374
1.375 elif name == "DTSTART":
1.376 page.td(class_="objectvalue %s replaced" % field, rowspan=2)
1.377 - page.a("First occurrence replaced by a separate event", href=self.link_to(uid, replaced))
1.378 + page.a("First occurrence replaced by a separate event", href=self.link_to(self.uid, replaced))
1.379 page.td.close()
1.380
1.381 page.tr.close()
1.382 @@ -544,10 +527,10 @@
1.383 # Handle the summary specially.
1.384
1.385 elif name == "SUMMARY":
1.386 - value = args.get("summary", [obj.get_value(name)])[0]
1.387 + value = args.get("summary", [self.obj.get_value(name)])[0]
1.388
1.389 page.td(class_="objectvalue summary")
1.390 - if self.is_organiser(obj):
1.391 + if self.is_organiser():
1.392 self._control("summary", "text", value, size=80)
1.393 else:
1.394 page.add(value)
1.395 @@ -568,12 +551,12 @@
1.396
1.397 # Obtain details of attendees to supply attributes.
1.398
1.399 - self.show_attendee(obj, i, value, attendee_map.get(value))
1.400 + self.show_attendee(i, value, attendee_map.get(value))
1.401 page.tr.close()
1.402
1.403 # Allow more attendees to be specified.
1.404
1.405 - if self.is_organiser(obj):
1.406 + if self.is_organiser():
1.407 if not first:
1.408 page.tr()
1.409
1.410 @@ -602,17 +585,17 @@
1.411 page.tbody.close()
1.412 page.table.close()
1.413
1.414 - self.show_recurrences(obj, errors)
1.415 - self.show_conflicting_events(obj)
1.416 - self.show_request_controls(obj)
1.417 + self.show_recurrences(errors)
1.418 + self.show_conflicting_events()
1.419 + self.show_request_controls()
1.420
1.421 page.form.close()
1.422
1.423 - def show_attendee(self, obj, i, attendee, attendee_attr):
1.424 + def show_attendee(self, i, attendee, attendee_attr):
1.425
1.426 """
1.427 - For the given object 'obj', show the attendee in position 'i' with the
1.428 - given 'attendee' value, having 'attendee_attr' as any stored attributes.
1.429 + For the current object, show the attendee in position 'i' with the given
1.430 + 'attendee' value, having 'attendee_attr' as any stored attributes.
1.431 """
1.432
1.433 page = self.page
1.434 @@ -625,7 +608,7 @@
1.435
1.436 # Show a form control as organiser for new attendees.
1.437
1.438 - if self.is_organiser(obj) and (not existing or not obj.is_shared()):
1.439 + if self.is_organiser() and (not existing or not self.obj.is_shared()):
1.440 self._control("attendee", "value", attendee, size="40")
1.441 else:
1.442 self._control("attendee", "hidden", attendee)
1.443 @@ -641,7 +624,7 @@
1.444 # button in order to refresh the page and show a control for
1.445 # the current user, if indicated.
1.446
1.447 - elif self.is_organiser(obj) and not existing:
1.448 + elif self.is_organiser() and not existing:
1.449 self._control("partstat-refresh", "submit", "refresh", id="partstat-%d" % i, class_="refresh")
1.450 page.label(dict(self.partstat_items).get(partstat, ""), for_="partstat-%s" % i, class_="partstat")
1.451 else:
1.452 @@ -649,11 +632,11 @@
1.453
1.454 # Permit organisers to remove attendees.
1.455
1.456 - if self.is_organiser(obj):
1.457 + if self.is_organiser():
1.458
1.459 # Permit the removal of newly-added attendees.
1.460
1.461 - remove_type = (not existing or not obj.is_shared() or attendee == self.user) and "submit" or "checkbox"
1.462 + remove_type = (not existing or not self.obj.is_shared() or attendee == self.user) and "submit" or "checkbox"
1.463 self._control("remove", remove_type, str(i), str(i) in args.get("remove", []), id="remove-%d" % i, class_="remove")
1.464
1.465 page.label("Remove", for_="remove-%d" % i, class_="remove")
1.466 @@ -664,48 +647,44 @@
1.467
1.468 page.td.close()
1.469
1.470 - def show_recurrences(self, obj, errors=None):
1.471 + def show_recurrences(self, errors=None):
1.472
1.473 """
1.474 - Show recurrences for the object having the given representation 'obj'.
1.475 - If 'errors' is given, show a suitable message for the different errors
1.476 - provided.
1.477 + Show recurrences for the current object. If 'errors' is given, show a
1.478 + suitable message for the different errors provided.
1.479 """
1.480
1.481 page = self.page
1.482
1.483 # Obtain any parent object if this object is a specific recurrence.
1.484
1.485 - uid = obj.get_uid()
1.486 - recurrenceid = obj.get_recurrenceid()
1.487 -
1.488 - if recurrenceid:
1.489 - parent = self.get_stored_object(uid, None)
1.490 + if self.recurrenceid:
1.491 + parent = self.get_stored_object(self.uid, None)
1.492 if not parent:
1.493 return
1.494
1.495 page.p()
1.496 - page.a("This event modifies a recurring event.", href=self.link_to(uid))
1.497 + page.a("This event modifies a recurring event.", href=self.link_to(self.uid))
1.498 page.p.close()
1.499
1.500 # Obtain the periods associated with the event.
1.501 # NOTE: Add a control to add recurrences here.
1.502
1.503 - recurrences = self.get_current_recurrences(obj)
1.504 + recurrences = self.get_current_recurrences()
1.505
1.506 if len(recurrences) < 1:
1.507 return
1.508
1.509 - recurrenceids = self._get_recurrences(uid)
1.510 + recurrenceids = self._get_recurrences(self.uid)
1.511
1.512 page.p("This event occurs on the following occasions within the next %d days:" % self.get_window_size())
1.513
1.514 # Show each recurrence in a separate table if editable.
1.515
1.516 - if self.is_organiser(obj) and recurrences:
1.517 + if self.is_organiser() and recurrences:
1.518
1.519 for index, period in enumerate(recurrences):
1.520 - self.show_recurrence(obj, index, period, recurrenceid, recurrenceids, errors)
1.521 + self.show_recurrence(index, period, self.recurrenceid, recurrenceids, errors)
1.522
1.523 # Otherwise, use a compact single table.
1.524
1.525 @@ -722,21 +701,21 @@
1.526
1.527 for index, period in enumerate(recurrences):
1.528 page.tr()
1.529 - self.show_recurrence_label(period, recurrenceid, recurrenceids, True)
1.530 - self.show_recurrence_label(period, recurrenceid, recurrenceids, False)
1.531 + self.show_recurrence_label(period, self.recurrenceid, recurrenceids, True)
1.532 + self.show_recurrence_label(period, self.recurrenceid, recurrenceids, False)
1.533 page.tr.close()
1.534
1.535 page.tbody.close()
1.536 page.table.close()
1.537
1.538 - def show_recurrence(self, obj, index, period, recurrenceid, recurrenceids, errors=None):
1.539 + def show_recurrence(self, index, period, recurrenceid, recurrenceids, errors=None):
1.540
1.541 """
1.542 - Show recurrence controls for a recurrence provided by 'obj' with the
1.543 - given 'index' position in the list of periods, the given 'period'
1.544 - details, where a 'recurrenceid' indicates any specific recurrence, and
1.545 - where 'recurrenceids' indicates all known additional recurrences for the
1.546 - object.
1.547 + Show recurrence controls for a recurrence provided by the current object
1.548 + with the given 'index' position in the list of periods, the given
1.549 + 'period' details, where a 'recurrenceid' indicates any specific
1.550 + recurrence, and where 'recurrenceids' indicates all known additional
1.551 + recurrences for the object.
1.552
1.553 If 'errors' is given, show a suitable message for the different errors
1.554 provided.
1.555 @@ -761,12 +740,12 @@
1.556 page.tr()
1.557 error = errors and ("dtstart", index) in errors and " error" or ""
1.558 page.th("Start", class_="objectheading start%s" % error)
1.559 - self.show_recurrence_controls(obj, index, period, recurrenceid, recurrenceids, True)
1.560 + self.show_recurrence_controls(index, period, recurrenceid, recurrenceids, True)
1.561 page.tr.close()
1.562 page.tr()
1.563 error = errors and ("dtend", index) in errors and " error" or ""
1.564 page.th("End", class_="objectheading end%s" % error)
1.565 - self.show_recurrence_controls(obj, index, period, recurrenceid, recurrenceids, False)
1.566 + self.show_recurrence_controls(index, period, recurrenceid, recurrenceids, False)
1.567 page.tr.close()
1.568
1.569 # Permit the removal of recurrences.
1.570 @@ -776,7 +755,7 @@
1.571 page.th("")
1.572 page.td()
1.573
1.574 - remove_type = not obj.is_shared() or not period.origin and "submit" or "checkbox"
1.575 + remove_type = not self.obj.is_shared() or not period.origin and "submit" or "checkbox"
1.576 self._control("recur-remove", remove_type, str(index),
1.577 str(index) in args.get("recur-remove", []),
1.578 id="recur-remove-%d" % index, class_="remove")
1.579 @@ -795,28 +774,24 @@
1.580
1.581 page.div.close()
1.582
1.583 - def show_conflicting_events(self, obj):
1.584 + def show_conflicting_events(self):
1.585
1.586 - """
1.587 - Show conflicting events for the object having the representation 'obj'.
1.588 - """
1.589 + "Show conflicting events for the current object."
1.590
1.591 page = self.page
1.592 - uid = obj.get_uid()
1.593 - recurrenceid = obj.get_recurrenceid()
1.594 - recurrenceids = self._get_active_recurrences(uid)
1.595 + recurrenceids = self._get_active_recurrences(self.uid)
1.596
1.597 # Obtain the user's timezone.
1.598
1.599 tzid = self.get_tzid()
1.600 - periods = self.get_periods(obj)
1.601 + periods = self.get_periods(self.obj)
1.602
1.603 # Indicate whether there are conflicting events.
1.604
1.605 conflicts = []
1.606 - attendee_map = uri_dict(obj.get_value_map("ATTENDEE"))
1.607 + attendee_map = uri_dict(self.obj.get_value_map("ATTENDEE"))
1.608
1.609 - for participant in self.get_current_attendees(obj):
1.610 + for participant in self.get_current_attendees():
1.611 if participant == self.user:
1.612 freebusy = self.store.get_freebusy(participant)
1.613 else:
1.614 @@ -827,21 +802,21 @@
1.615
1.616 # Obtain any time zone details from the suggested event.
1.617
1.618 - _dtstart, attr = obj.get_item("DTSTART")
1.619 + _dtstart, attr = self.obj.get_item("DTSTART")
1.620 tzid = attr.get("TZID", tzid)
1.621
1.622 # Show any conflicts with periods of actual attendance.
1.623
1.624 participant_attr = attendee_map.get(participant)
1.625 partstat = participant_attr and participant_attr.get("PARTSTAT")
1.626 - recurrences = obj.get_recurrence_start_points(recurrenceids, tzid)
1.627 + recurrences = self.obj.get_recurrence_start_points(recurrenceids, tzid)
1.628
1.629 for p in have_conflict(freebusy, periods, True):
1.630 - if not recurrenceid and p.is_replaced(recurrences):
1.631 + if not self.recurrenceid and p.is_replaced(recurrences):
1.632 continue
1.633
1.634 if ( # Unidentified or different event
1.635 - (p.uid != uid or recurrenceid and p.recurrenceid and p.recurrenceid != recurrenceid) and
1.636 + (p.uid != self.uid or self.recurrenceid and p.recurrenceid and p.recurrenceid != self.recurrenceid) and
1.637 # Different period or unclear participation with the same period
1.638 (p not in periods or not partstat in ("ACCEPTED", "TENTATIVE")) and
1.639 # Participant not limited to organising
1.640 @@ -945,19 +920,19 @@
1.641 id=_id("dttimes-enable", index)
1.642 )
1.643
1.644 - def show_datetime_controls(self, obj, formdate, show_start):
1.645 + def show_datetime_controls(self, formdate, show_start):
1.646
1.647 """
1.648 - Show datetime details from the given 'obj' for the 'formdate', showing
1.649 - start details if 'show_start' is set to a true value. Details will
1.650 - appear as controls for organisers and labels for attendees.
1.651 + Show datetime details from the current object for the 'formdate',
1.652 + showing start details if 'show_start' is set to a true value. Details
1.653 + will appear as controls for organisers and labels for attendees.
1.654 """
1.655
1.656 page = self.page
1.657
1.658 # Show controls for editing as organiser.
1.659
1.660 - if self.is_organiser(obj):
1.661 + if self.is_organiser():
1.662 page.td(class_="objectvalue dt%s" % (show_start and "start" or "end"))
1.663
1.664 if show_start:
1.665 @@ -989,11 +964,11 @@
1.666 else:
1.667 page.td("(Unrecognised date)")
1.668
1.669 - def show_recurrence_controls(self, obj, index, period, recurrenceid, recurrenceids, show_start):
1.670 + def show_recurrence_controls(self, index, period, recurrenceid, recurrenceids, show_start):
1.671
1.672 """
1.673 - Show datetime details from the given 'obj' for the recurrence having the
1.674 - given 'index', with the recurrence period described by 'period',
1.675 + Show datetime details from the current object for the recurrence having
1.676 + the given 'index', with the recurrence period described by 'period',
1.677 indicating a start, end and origin of the period from the event details,
1.678 employing any 'recurrenceid' and 'recurrenceids' for the object to
1.679 configure the displayed information.
1.680 @@ -1011,7 +986,7 @@
1.681
1.682 # Show controls for editing as organiser.
1.683
1.684 - if self.is_organiser(obj) and not replaced:
1.685 + if self.is_organiser() and not replaced:
1.686 page.td(class_="objectvalue dt%s" % (show_start and "start" or "end"))
1.687
1.688 read_only = period.origin == "RRULE"
1.689 @@ -1084,17 +1059,18 @@
1.690
1.691 uid, recurrenceid, section = self.get_identifiers(path_info)
1.692 obj = self.get_stored_object(uid, recurrenceid, section)
1.693 + self.set_object(obj)
1.694
1.695 if not obj:
1.696 return False
1.697
1.698 - errors = self.handle_request(obj)
1.699 + errors = self.handle_request()
1.700
1.701 if not errors:
1.702 return True
1.703
1.704 self.new_page(title="Event")
1.705 - self.show_object_on_page(obj, errors)
1.706 + self.show_object_on_page(errors)
1.707
1.708 return True
1.709