1.1 --- a/imiptools/content.py Thu Mar 05 16:30:13 2015 +0100
1.2 +++ b/imiptools/content.py Thu Mar 05 17:15:57 2015 +0100
1.3 @@ -173,19 +173,28 @@
1.4
1.5 remove_period(freebusy, self.uid, self.recurrenceid)
1.6
1.7 - def remove_freebusy_for_recurrences(self, freebusy):
1.8 + def remove_freebusy_for_recurrences(self, freebusy, recurrenceids=None):
1.9
1.10 """
1.11 Remove from 'freebusy' any original recurrence from parent free/busy
1.12 details for the current object, if the current object is a specific
1.13 additional recurrence. Otherwise, remove all additional recurrence
1.14 - information.
1.15 + information corresponding to 'recurrenceids', or if omitted, all
1.16 + recurrences.
1.17 """
1.18
1.19 if self.recurrenceid:
1.20 remove_affected_period(freebusy, self.uid, self.recurrenceid)
1.21 else:
1.22 - remove_additional_periods(freebusy, self.uid)
1.23 + # Remove obsolete recurrence periods.
1.24 +
1.25 + remove_additional_periods(freebusy, self.uid, recurrenceids)
1.26 +
1.27 + # Remove original periods affected by additional recurrences.
1.28 +
1.29 + if recurrenceids:
1.30 + for recurrenceid in recurrenceids:
1.31 + remove_affected_period(freebusy, self.uid, recurrenceid)
1.32
1.33 def _update_freebusy(self, freebusy, periods, recurrenceid, transp=None):
1.34
1.35 @@ -247,7 +256,7 @@
1.36 self.update_freebusy_for_participant(freebusy, periods, participant_attr,
1.37 for_organiser and self.is_not_attendee(participant, self.obj))
1.38
1.39 - self.remove_freebusy_for_recurrences(freebusy)
1.40 + self.remove_freebusy_for_recurrences(freebusy, self.store.get_recurrences(user, self.uid))
1.41 self.store.set_freebusy_for_other(user, freebusy, participant)
1.42
1.43 def update_freebusy_from_organiser(self, attendee, organiser_item):
2.1 --- a/imiptools/handlers/person_outgoing.py Thu Mar 05 16:30:13 2015 +0100
2.2 +++ b/imiptools/handlers/person_outgoing.py Thu Mar 05 17:15:57 2015 +0100
2.3 @@ -103,7 +103,7 @@
2.4 # details depending on whether an additional recurrence or a
2.5 # complete event are being handled, respectively.
2.6
2.7 - self.remove_freebusy_for_recurrences(freebusy)
2.8 + self.remove_freebusy_for_recurrences(freebusy, self.store.get_recurrences(identity, self.uid))
2.9 self.store.set_freebusy(identity, freebusy)
2.10
2.11 if self.publisher:
3.1 --- a/imiptools/period.py Thu Mar 05 16:30:13 2015 +0100
3.2 +++ b/imiptools/period.py Thu Mar 05 17:15:57 2015 +0100
3.3 @@ -82,17 +82,23 @@
3.4 else:
3.5 i += 1
3.6
3.7 -def remove_additional_periods(freebusy, uid):
3.8 +def remove_additional_periods(freebusy, uid, recurrenceids=None):
3.9
3.10 """
3.11 Remove from 'freebusy' all periods associated with 'uid' having a
3.12 recurrence identifier indicating an additional or modified period.
3.13 +
3.14 + If 'recurrenceids' is specified, remove all periods associated with 'uid'
3.15 + that do not have a recurrence identifier in the given list.
3.16 """
3.17
3.18 i = 0
3.19 while i < len(freebusy):
3.20 t = freebusy[i]
3.21 - if len(t) >= 5 and t[2] == uid and t[4]:
3.22 + if len(t) >= 5 and t[2] == uid and t[4] and (
3.23 + recurrenceids is None or
3.24 + recurrenceids is not None and t[4] not in recurrenceids
3.25 + ):
3.26 del freebusy[i]
3.27 else:
3.28 i += 1