# HG changeset patch # User Paul Boddie # Date 1445182322 -7200 # Node ID fb381a0c09f25fed9f191579752ea252a14b092f # Parent b38466ae1e51ae0447661522462e257e02a78055 Copy rules and exceptions from counter-proposals so that the resulting periods match the presented periods. diff -r b38466ae1e51 -r fb381a0c09f2 imiptools/data.py --- a/imiptools/data.py Sun Oct 18 13:56:13 2015 +0200 +++ b/imiptools/data.py Sun Oct 18 17:32:02 2015 +0200 @@ -424,6 +424,39 @@ return main_changed or old_values != set(self.get_date_values("RDATE") or []) + def set_rule(self, rule): + + """ + Set the given 'rule' in this object, replacing the previous RRULE + property, returning whether the object has changed. The provided 'rule' + must be an item. + """ + + if not rule: + return False + + old_rrule = self.get_item("RRULE") + self["RRULE"] = [rule] + return old_rrule != rule + + def set_exceptions(self, exceptions): + + """ + Set the given 'exceptions' in this object, replacing the previous EXDATE + properties, returning whether the object has changed. The provided + 'exceptions' must be a collection of items. + """ + + old_exdates = set(self.get_date_values("EXDATE") or []) + if exceptions: + self["EXDATE"] = exceptions + return old_exdates != set(self.get_date_values("EXDATE") or []) + elif old_exdates: + del self["EXDATE"] + return True + else: + return False + def update_dtstamp(self): "Update the DTSTAMP in the object." diff -r b38466ae1e51 -r fb381a0c09f2 imipweb/event.py --- a/imipweb/event.py Sun Oct 18 13:56:13 2015 +0200 +++ b/imipweb/event.py Sun Oct 18 17:32:02 2015 +0200 @@ -818,6 +818,7 @@ # Set the periods in the object, first obtaining removed and # modified period information. + # NOTE: Currently, rules are not updated. to_unschedule, to_exclude = self.get_removed_periods(periods) periods = set(periods) @@ -905,6 +906,8 @@ attendee_uri = get_uri(args.get("counter", [])[i]) obj = self.get_stored_object(self.uid, self.recurrenceid, "counters", attendee_uri) self.obj.set_periods(self.get_periods(obj)) + self.obj.set_rule(obj.get_item("RRULE")) + self.obj.set_exceptions(obj.get_items("EXDATE")) break # Remove counter-proposals and issue a new invitation.