1.1 --- a/imiptools/handlers/person_outgoing.py Tue Feb 10 17:30:13 2015 +0100
1.2 +++ b/imiptools/handlers/person_outgoing.py Tue Feb 10 17:31:09 2015 +0100
1.3 @@ -21,7 +21,7 @@
1.4 """
1.5
1.6 from imiptools.content import Handler
1.7 -from imiptools.data import uri_item
1.8 +from imiptools.data import uri_dict, uri_item, uri_values
1.9 from imiptools.dates import get_default_timezone
1.10 from imiptools.profile import Preferences
1.11
1.12 @@ -102,13 +102,30 @@
1.13
1.14 identity, attr = item
1.15
1.16 - # Store the object, updating any sequence information.
1.17 + # Only cancel the event completely if all attendees are given.
1.18 +
1.19 + obj = self.get_object(identity)
1.20
1.21 - self.store.set_event(identity, self.uid, self.obj.to_node())
1.22 + attendees = uri_dict(obj.get_value_map("ATTENDEE"))
1.23 + all_attendees = set(attendees.keys())
1.24 + given_attendees = set(uri_values(self.obj.get_values("ATTENDEE")))
1.25 +
1.26 + if given_attendees == all_attendees:
1.27 + self.store.cancel_event(identity, self.uid)
1.28
1.29 - # Cancel the event.
1.30 + # Otherwise, remove the given attendees and update the event.
1.31 +
1.32 + else:
1.33 + for attendee in given_attendees:
1.34 + del attendees[attendee]
1.35 + obj["ATTENDEE"] = attendees.items()
1.36
1.37 - self.store.cancel_event(identity, self.uid)
1.38 + # Update the stored object with sequence information.
1.39 +
1.40 + obj["SEQUENCE"] = self.obj.get_items("SEQUENCE")
1.41 + obj["DTSTAMP"] = self.obj.get_items("DTSTAMP")
1.42 +
1.43 + self.store.set_event(identity, self.uid, obj.to_node())
1.44
1.45 # Remove any associated request.
1.46