# HG changeset patch # User Paul Boddie # Date 1443741608 -7200 # Node ID d5dc0ff83bcc3de56cbabfdc7a12a9abca5a36b7 # Parent 1f8d646247f488c3d2f27bbf59691d95b284fd1e Remove any previous cancellations when handling events. diff -r 1f8d646247f4 -r d5dc0ff83bcc imip_store.py --- a/imip_store.py Tue Sep 29 23:26:49 2015 +0200 +++ b/imip_store.py Fri Oct 02 01:20:08 2015 +0200 @@ -856,6 +856,40 @@ return False + def remove_cancellations(self, user, uid, recurrenceid=None): + + """ + Remove cancellations for 'user' for any event having the given 'uid'. If + the optional 'recurrenceid' is specified, a specific instance or + occurrence of an event is affected. + """ + + # Remove all recurrence cancellations if a general event is indicated. + + if not recurrenceid: + for _recurrenceid in self.get_cancelled_recurrences(user, uid): + self.remove_cancellation(user, uid, _recurrenceid) + + return self.remove_cancellation(user, uid, recurrenceid) + + def remove_cancellation(self, user, uid, recurrenceid=None): + + """ + Remove a cancellation for 'user' for the event having the given 'uid'. + If the optional 'recurrenceid' is specified, a specific instance or + occurrence of an event is affected. + """ + + # Remove any parent event cancellation or a specific recurrence + # cancellation if indicated. + + filename = self.get_event_filename(user, uid, recurrenceid, "cancellations") + + if filename and exists(filename): + return self._remove_object(filename) + + return False + class FilePublisher(FileBase): "A publisher of objects." diff -r 1f8d646247f4 -r d5dc0ff83bcc imiptools/handlers/person.py --- a/imiptools/handlers/person.py Tue Sep 29 23:26:49 2015 +0200 +++ b/imiptools/handlers/person.py Fri Oct 02 01:20:08 2015 +0200 @@ -132,9 +132,13 @@ return False # Remove additional recurrences if handling a complete event. + # Also remove any previous cancellations involving this event. if not self.recurrenceid: self.store.remove_recurrences(self.user, self.uid) + self.store.remove_cancellations(self.user, self.uid) + else: + self.store.remove_cancellation(self.user, self.uid, self.recurrenceid) # Queue any request, if appropriate. diff -r 1f8d646247f4 -r d5dc0ff83bcc imiptools/handlers/person_outgoing.py --- a/imiptools/handlers/person_outgoing.py Tue Sep 29 23:26:49 2015 +0200 +++ b/imiptools/handlers/person_outgoing.py Fri Oct 02 01:20:08 2015 +0200 @@ -101,9 +101,13 @@ self.store.set_event(self.user, self.uid, self.recurrenceid, self.obj.to_node()) # Remove additional recurrences if handling a complete event. + # Also remove any previous cancellations involving this event. if not self.recurrenceid: self.store.remove_recurrences(self.user, self.uid) + self.store.remove_cancellations(self.user, self.uid) + else: + self.store.remove_cancellation(self.user, self.uid, self.recurrenceid) else: # Obtain valid attendees, merging their attendance with the stored diff -r 1f8d646247f4 -r d5dc0ff83bcc imiptools/handlers/resource.py --- a/imiptools/handlers/resource.py Tue Sep 29 23:26:49 2015 +0200 +++ b/imiptools/handlers/resource.py Fri Oct 02 01:20:08 2015 +0200 @@ -157,9 +157,13 @@ self.store.set_event(self.user, self.uid, self.recurrenceid, event) # Remove additional recurrences if handling a complete event. + # Also remove any previous cancellations involving this event. if not self.recurrenceid: self.store.remove_recurrences(self.user, self.uid) + self.store.remove_cancellations(self.user, self.uid) + else: + self.store.remove_cancellation(self.user, self.uid, self.recurrenceid) # Make a version of the object with just this attendee, update the # DTSTAMP in the response, and return the object for sending.