imip-agent

Changeset

796:d5dc0ff83bcc
2015-10-02 Paul Boddie raw files shortlog changelog graph Remove any previous cancellations when handling events.
imip_store.py (file) imiptools/handlers/person.py (file) imiptools/handlers/person_outgoing.py (file) imiptools/handlers/resource.py (file)
     1.1 --- a/imip_store.py	Tue Sep 29 23:26:49 2015 +0200
     1.2 +++ b/imip_store.py	Fri Oct 02 01:20:08 2015 +0200
     1.3 @@ -856,6 +856,40 @@
     1.4  
     1.5          return False
     1.6  
     1.7 +    def remove_cancellations(self, user, uid, recurrenceid=None):
     1.8 +
     1.9 +        """
    1.10 +        Remove cancellations for 'user' for any event having the given 'uid'. If
    1.11 +        the optional 'recurrenceid' is specified, a specific instance or
    1.12 +        occurrence of an event is affected.
    1.13 +        """
    1.14 +
    1.15 +        # Remove all recurrence cancellations if a general event is indicated.
    1.16 +
    1.17 +        if not recurrenceid:
    1.18 +            for _recurrenceid in self.get_cancelled_recurrences(user, uid):
    1.19 +                self.remove_cancellation(user, uid, _recurrenceid)
    1.20 +
    1.21 +        return self.remove_cancellation(user, uid, recurrenceid)
    1.22 +
    1.23 +    def remove_cancellation(self, user, uid, recurrenceid=None):
    1.24 +
    1.25 +        """
    1.26 +        Remove a cancellation for 'user' for the event having the given 'uid'.
    1.27 +        If the optional 'recurrenceid' is specified, a specific instance or
    1.28 +        occurrence of an event is affected.
    1.29 +        """
    1.30 +
    1.31 +        # Remove any parent event cancellation or a specific recurrence
    1.32 +        # cancellation if indicated.
    1.33 +
    1.34 +        filename = self.get_event_filename(user, uid, recurrenceid, "cancellations")
    1.35 +
    1.36 +        if filename and exists(filename):
    1.37 +            return self._remove_object(filename)
    1.38 +
    1.39 +        return False
    1.40 +
    1.41  class FilePublisher(FileBase):
    1.42  
    1.43      "A publisher of objects."
     2.1 --- a/imiptools/handlers/person.py	Tue Sep 29 23:26:49 2015 +0200
     2.2 +++ b/imiptools/handlers/person.py	Fri Oct 02 01:20:08 2015 +0200
     2.3 @@ -132,9 +132,13 @@
     2.4                  return False
     2.5  
     2.6              # Remove additional recurrences if handling a complete event.
     2.7 +            # Also remove any previous cancellations involving this event.
     2.8  
     2.9              if not self.recurrenceid:
    2.10                  self.store.remove_recurrences(self.user, self.uid)
    2.11 +                self.store.remove_cancellations(self.user, self.uid)
    2.12 +            else:
    2.13 +                self.store.remove_cancellation(self.user, self.uid, self.recurrenceid)
    2.14  
    2.15              # Queue any request, if appropriate.
    2.16  
     3.1 --- a/imiptools/handlers/person_outgoing.py	Tue Sep 29 23:26:49 2015 +0200
     3.2 +++ b/imiptools/handlers/person_outgoing.py	Fri Oct 02 01:20:08 2015 +0200
     3.3 @@ -101,9 +101,13 @@
     3.4              self.store.set_event(self.user, self.uid, self.recurrenceid, self.obj.to_node())
     3.5  
     3.6              # Remove additional recurrences if handling a complete event.
     3.7 +            # Also remove any previous cancellations involving this event.
     3.8  
     3.9              if not self.recurrenceid:
    3.10                  self.store.remove_recurrences(self.user, self.uid)
    3.11 +                self.store.remove_cancellations(self.user, self.uid)
    3.12 +            else:
    3.13 +                self.store.remove_cancellation(self.user, self.uid, self.recurrenceid)
    3.14  
    3.15          else:
    3.16              # Obtain valid attendees, merging their attendance with the stored
     4.1 --- a/imiptools/handlers/resource.py	Tue Sep 29 23:26:49 2015 +0200
     4.2 +++ b/imiptools/handlers/resource.py	Fri Oct 02 01:20:08 2015 +0200
     4.3 @@ -157,9 +157,13 @@
     4.4              self.store.set_event(self.user, self.uid, self.recurrenceid, event)
     4.5  
     4.6              # Remove additional recurrences if handling a complete event.
     4.7 +            # Also remove any previous cancellations involving this event.
     4.8  
     4.9              if not self.recurrenceid:
    4.10                  self.store.remove_recurrences(self.user, self.uid)
    4.11 +                self.store.remove_cancellations(self.user, self.uid)
    4.12 +            else:
    4.13 +                self.store.remove_cancellation(self.user, self.uid, self.recurrenceid)
    4.14  
    4.15          # Make a version of the object with just this attendee, update the
    4.16          # DTSTAMP in the response, and return the object for sending.