# HG changeset patch # User Paul Boddie # Date 1425572157 -3600 # Node ID 78ee44adfe292a644ab4eb4ef7c8288df2a72ff1 # Parent f5fe45d84ecc8e50480795336f2aeec0f5f17313 Preserve potentially active recurrences when cleaning free/busy information so that special/additional recurrences can be accepted before their parent event and not be subsequently removed. diff -r f5fe45d84ecc -r 78ee44adfe29 imiptools/content.py --- a/imiptools/content.py Thu Mar 05 16:30:13 2015 +0100 +++ b/imiptools/content.py Thu Mar 05 17:15:57 2015 +0100 @@ -173,19 +173,28 @@ remove_period(freebusy, self.uid, self.recurrenceid) - def remove_freebusy_for_recurrences(self, freebusy): + def remove_freebusy_for_recurrences(self, freebusy, recurrenceids=None): """ Remove from 'freebusy' any original recurrence from parent free/busy details for the current object, if the current object is a specific additional recurrence. Otherwise, remove all additional recurrence - information. + information corresponding to 'recurrenceids', or if omitted, all + recurrences. """ if self.recurrenceid: remove_affected_period(freebusy, self.uid, self.recurrenceid) else: - remove_additional_periods(freebusy, self.uid) + # Remove obsolete recurrence periods. + + remove_additional_periods(freebusy, self.uid, recurrenceids) + + # Remove original periods affected by additional recurrences. + + if recurrenceids: + for recurrenceid in recurrenceids: + remove_affected_period(freebusy, self.uid, recurrenceid) def _update_freebusy(self, freebusy, periods, recurrenceid, transp=None): @@ -247,7 +256,7 @@ self.update_freebusy_for_participant(freebusy, periods, participant_attr, for_organiser and self.is_not_attendee(participant, self.obj)) - self.remove_freebusy_for_recurrences(freebusy) + self.remove_freebusy_for_recurrences(freebusy, self.store.get_recurrences(user, self.uid)) self.store.set_freebusy_for_other(user, freebusy, participant) def update_freebusy_from_organiser(self, attendee, organiser_item): diff -r f5fe45d84ecc -r 78ee44adfe29 imiptools/handlers/person_outgoing.py --- a/imiptools/handlers/person_outgoing.py Thu Mar 05 16:30:13 2015 +0100 +++ b/imiptools/handlers/person_outgoing.py Thu Mar 05 17:15:57 2015 +0100 @@ -103,7 +103,7 @@ # details depending on whether an additional recurrence or a # complete event are being handled, respectively. - self.remove_freebusy_for_recurrences(freebusy) + self.remove_freebusy_for_recurrences(freebusy, self.store.get_recurrences(identity, self.uid)) self.store.set_freebusy(identity, freebusy) if self.publisher: diff -r f5fe45d84ecc -r 78ee44adfe29 imiptools/period.py --- a/imiptools/period.py Thu Mar 05 16:30:13 2015 +0100 +++ b/imiptools/period.py Thu Mar 05 17:15:57 2015 +0100 @@ -82,17 +82,23 @@ else: i += 1 -def remove_additional_periods(freebusy, uid): +def remove_additional_periods(freebusy, uid, recurrenceids=None): """ Remove from 'freebusy' all periods associated with 'uid' having a recurrence identifier indicating an additional or modified period. + + If 'recurrenceids' is specified, remove all periods associated with 'uid' + that do not have a recurrence identifier in the given list. """ i = 0 while i < len(freebusy): t = freebusy[i] - if len(t) >= 5 and t[2] == uid and t[4]: + if len(t) >= 5 and t[2] == uid and t[4] and ( + recurrenceids is None or + recurrenceids is not None and t[4] not in recurrenceids + ): del freebusy[i] else: i += 1