# HG changeset patch # User Paul Boddie # Date 1423172148 -3600 # Node ID 3a37d5b57c4e9c9b0d05cfbd03a059c178226cfa # Parent 41f5fae7bb834047f8c32b04af458bf3dd909e2d Added organiser/attendee verification for free/busy updates; tidied up slightly. diff -r 41f5fae7bb83 -r 3a37d5b57c4e imiptools/handlers/person.py --- a/imiptools/handlers/person.py Thu Feb 05 22:22:41 2015 +0100 +++ b/imiptools/handlers/person.py Thu Feb 05 22:35:48 2015 +0100 @@ -20,7 +20,7 @@ """ from imiptools.content import Handler -from imiptools.data import get_address, get_uri, uri_dict, uri_items +from imiptools.data import get_uri from imiptools.handlers.common import CommonFreebusy from imiptools.profile import Preferences @@ -28,7 +28,7 @@ "Handling mechanisms specific to people." - def _record_and_deliver(self, from_organiser=True, queue=False, cancel=False): + def _record(self, from_organiser=True, queue=False, cancel=False): oa = self.require_organiser_and_attendees(from_organiser) if not oa: @@ -79,7 +79,12 @@ "Record free/busy information for the received information." - senders = self.obj.get_items(from_organiser and "ORGANIZER" or "ATTENDEE") + oa = self.require_organiser_and_attendees(from_organiser) + if not oa: + return + + organiser_item, attendees = oa + senders = from_organiser and [organiser_item] or attendees if not senders: return @@ -96,7 +101,7 @@ except ValueError: pass - for sender, sender_attr in uri_items(senders): + for sender, sender_attr in senders: self.store.set_freebusy_for_other(get_uri(self.recipient), freebusy, sender) class Event(PersonHandler): @@ -113,7 +118,7 @@ "Queue a cancellation of any active event." - self._record_and_deliver(from_organiser=True, queue=False, cancel=True) + self._record(from_organiser=True, queue=False, cancel=True) return self.wrap("A cancellation has been received.", link=False) def counter(self): @@ -132,28 +137,28 @@ "Register details of any relevant event." - self._record_and_deliver(from_organiser=True, queue=False) + self._record(from_organiser=True, queue=False) return self.wrap("Details of an event have been received.") def refresh(self): "Update details of any active event." - self._record_and_deliver(from_organiser=True, queue=False) + self._record(from_organiser=True, queue=False) return self.wrap("An event update has been received.") def reply(self): "Record replies and notify the recipient." - self._record_and_deliver(from_organiser=False, queue=False) + self._record(from_organiser=False, queue=False) return self.wrap("A reply has been received.") def request(self): "Hold requests and notify the recipient." - self._record_and_deliver(from_organiser=True, queue=True) + self._record(from_organiser=True, queue=True) return self.wrap("A request has been received.") class Freebusy(PersonHandler, CommonFreebusy): @@ -217,7 +222,7 @@ # NOTE: Register details of any relevant entry. - self._record_and_deliver(from_organiser=True, queue=False) + self._record(from_organiser=True, queue=False) return self.wrap("Details of a journal entry have been received.") class Todo(PersonHandler): @@ -252,28 +257,28 @@ "Register details of any relevant item." - self._record_and_deliver(from_organiser=True, queue=False) + self._record(from_organiser=True, queue=False) return self.wrap("Details of an item have been received.") def refresh(self): "Update details of any active item." - self._record_and_deliver(from_organiser=True, queue=False) + self._record(from_organiser=True, queue=False) return self.wrap("An item update has been received.") def reply(self): "Record replies and notify the recipient." - self._record_and_deliver(from_organiser=False, queue=False) + self._record(from_organiser=False, queue=False) return self.wrap("A reply has been received.") def request(self): "Hold requests and notify the recipient." - self._record_and_deliver(from_organiser=True, queue=True) + self._record(from_organiser=True, queue=True) return self.wrap("A request has been received.") # Handler registry.