1.1 --- a/imiptools/content.py Wed Mar 04 18:03:35 2015 +0100
1.2 +++ b/imiptools/content.py Thu Mar 05 01:01:44 2015 +0100
1.3 @@ -182,7 +182,7 @@
1.4 if self.recurrenceid:
1.5 remove_affected_period(freebusy, self.uid, self.recurrenceid)
1.6
1.7 - def _update_freebusy(self, freebusy, periods, recurrenceid, transp=None):
1.8 + def _update_freebusy(self, freebusy, periods, recurrenceid, transp=None, replace_all=False):
1.9
1.10 """
1.11 Update the 'freebusy' collection with the given 'periods', indicating an
1.12 @@ -191,18 +191,18 @@
1.13 """
1.14
1.15 update_freebusy(freebusy, periods, transp or self.obj.get_value("TRANSP"),
1.16 - self.uid, recurrenceid)
1.17 + self.uid, recurrenceid, replace_all)
1.18
1.19 - def update_freebusy(self, freebusy, periods, transp=None):
1.20 + def update_freebusy(self, freebusy, periods, transp=None, replace_all=False):
1.21
1.22 """
1.23 Update the 'freebusy' collection for this event with the given
1.24 'periods'.
1.25 """
1.26
1.27 - self._update_freebusy(freebusy, periods, self.recurrenceid, transp)
1.28 + self._update_freebusy(freebusy, periods, self.recurrenceid, transp, replace_all)
1.29
1.30 - def update_freebusy_for_participant(self, freebusy, periods, attr, for_organiser=False):
1.31 + def update_freebusy_for_participant(self, freebusy, periods, attr, for_organiser=False, has_moved=False):
1.32
1.33 """
1.34 Update the 'freebusy' collection using the given 'periods', subject to
1.35 @@ -213,13 +213,13 @@
1.36 # Organisers employ a special transparency.
1.37
1.38 if for_organiser or attr.get("PARTSTAT") != "DECLINED":
1.39 - self.update_freebusy(freebusy, periods, transp=(for_organiser and "ORG" or None))
1.40 + self.update_freebusy(freebusy, periods, transp=(for_organiser and "ORG" or None), replace_all=has_moved)
1.41 else:
1.42 self.remove_from_freebusy(freebusy)
1.43
1.44 # Convenience methods for updating stored free/busy information.
1.45
1.46 - def update_freebusy_from_participant(self, user, participant_item, for_organiser):
1.47 + def update_freebusy_from_participant(self, user, participant_item, for_organiser, has_moved=False):
1.48
1.49 """
1.50 For the given 'user', record the free/busy information for the
1.51 @@ -240,19 +240,20 @@
1.52 # Record in the free/busy details unless a non-participating attendee.
1.53
1.54 self.update_freebusy_for_participant(freebusy, periods, participant_attr,
1.55 - for_organiser and self.is_not_attendee(participant, self.obj))
1.56 + for_organiser and self.is_not_attendee(participant, self.obj),
1.57 + has_moved)
1.58
1.59 self.remove_freebusy_for_original_recurrence(freebusy)
1.60 self.store.set_freebusy_for_other(user, freebusy, participant)
1.61
1.62 - def update_freebusy_from_organiser(self, attendee, organiser_item):
1.63 + def update_freebusy_from_organiser(self, attendee, organiser_item, has_moved=False):
1.64
1.65 """
1.66 For the 'attendee', record free/busy information from the
1.67 'organiser_item' (a value plus attributes).
1.68 """
1.69
1.70 - self.update_freebusy_from_participant(attendee, organiser_item, True)
1.71 + self.update_freebusy_from_participant(attendee, organiser_item, True, has_moved)
1.72
1.73 def update_freebusy_from_attendees(self, organiser, attendees):
1.74
1.75 @@ -511,6 +512,28 @@
1.76 sequence = self.obj.get_value("SEQUENCE") or "0"
1.77 self.obj["SEQUENCE"] = [(str(int(sequence) + (increment and 1 or 0)), {})]
1.78
1.79 + # Store modifications.
1.80 +
1.81 + def handle_moved_event(self, identity):
1.82 +
1.83 + """
1.84 + Determine whether a complete event is being moved, removing special
1.85 + recurrences in anticipation of their republication.
1.86 + """
1.87 +
1.88 + if self.recurrenceid:
1.89 + return False
1.90 +
1.91 + obj = self.get_object(identity)
1.92 +
1.93 + if obj.get_utc_datetime("DTSTART") == self.obj.get_utc_datetime("DTSTART"):
1.94 + return False
1.95 +
1.96 + # Remove recurrences associated with old recurrence identifiers.
1.97 +
1.98 + self.store.remove_recurrences(identity, self.uid)
1.99 + return True
1.100 +
1.101 def detach_recurrence(self, identity):
1.102
1.103 "Detach the current object from its parent if it is a recurrence."