1.1 --- a/imiptools/handlers/__init__.py Tue Apr 07 22:28:52 2015 +0200
1.2 +++ b/imiptools/handlers/__init__.py Tue Apr 07 22:30:06 2015 +0200
1.3 @@ -26,7 +26,7 @@
1.4 from imiptools.data import Object, \
1.5 get_address, get_uri, get_value, \
1.6 is_new_object, uri_dict, uri_item, uri_values
1.7 -from imiptools.dates import format_datetime, to_timezone
1.8 +from imiptools.dates import format_datetime, to_recurrence_start, to_timezone
1.9 from imiptools.period import can_schedule, remove_period, \
1.10 remove_additional_periods, remove_affected_period, \
1.11 update_freebusy
1.12 @@ -120,6 +120,12 @@
1.13
1.14 # Convenience methods for modifying free/busy collections.
1.15
1.16 + def to_recurrence_start(self, recurrenceid):
1.17 +
1.18 + "Get 'recurrenceid' in a form suitable for matching free/busy entries."
1.19 +
1.20 + return to_recurrence_start(recurrenceid, self.get_tzid())
1.21 +
1.22 def remove_from_freebusy(self, freebusy):
1.23
1.24 "Remove this event from the given 'freebusy' collection."
1.25 @@ -137,7 +143,8 @@
1.26 """
1.27
1.28 if self.recurrenceid:
1.29 - remove_affected_period(freebusy, self.uid, self.recurrenceid)
1.30 + recurrenceid = self.to_recurrence_start(self.recurrenceid)
1.31 + remove_affected_period(freebusy, self.uid, recurrenceid)
1.32 else:
1.33 # Remove obsolete recurrence periods.
1.34
1.35 @@ -147,6 +154,7 @@
1.36
1.37 if recurrenceids:
1.38 for recurrenceid in recurrenceids:
1.39 + recurrenceid = self.to_recurrence_start(recurrenceid)
1.40 remove_affected_period(freebusy, self.uid, recurrenceid)
1.41
1.42 def _update_freebusy(self, freebusy, periods, recurrenceid, transp=None):
1.43 @@ -480,8 +488,6 @@
1.44 # Set the complete event if not an additional occurrence.
1.45
1.46 event = obj.to_node()
1.47 - recurrenceid = format_datetime(obj.get_utc_datetime("RECURRENCE-ID"))
1.48 -
1.49 self.store.set_event(self.user, self.uid, self.recurrenceid, event)
1.50
1.51 return True
2.1 --- a/imiptools/period.py Tue Apr 07 22:28:52 2015 +0200
2.2 +++ b/imiptools/period.py Tue Apr 07 22:30:06 2015 +0200
2.3 @@ -157,22 +157,23 @@
2.4 else:
2.5 i += 1
2.6
2.7 -def remove_affected_period(freebusy, uid, recurrenceid):
2.8 +def remove_affected_period(freebusy, uid, start):
2.9
2.10 """
2.11 Remove from 'freebusy' a period associated with 'uid' that provides an
2.12 - occurrence starting at the given 'recurrenceid', where the recurrence
2.13 - identifier is used to provide an alternative time period whilst also acting
2.14 - as a reference to the originally-defined occurrence.
2.15 + occurrence starting at the given 'start' (provided by a recurrence
2.16 + identifier, converted to a datetime). A recurrence identifier is used to
2.17 + provide an alternative time period whilst also acting as a reference to the
2.18 + originally-defined occurrence.
2.19 """
2.20
2.21 - found = bisect_left(freebusy, Period(recurrenceid))
2.22 + found = bisect_left(freebusy, Period(start))
2.23 while found < len(freebusy):
2.24 fb = freebusy[found]
2.25
2.26 # Stop looking if the start no longer matches the recurrence identifier.
2.27
2.28 - if fb.start != recurrenceid:
2.29 + if fb.start != start:
2.30 return
2.31
2.32 # If the period belongs to the parent object, remove it and return.
3.1 --- a/imipweb/resource.py Tue Apr 07 22:28:52 2015 +0200
3.2 +++ b/imipweb/resource.py Tue Apr 07 22:30:06 2015 +0200
3.3 @@ -22,7 +22,7 @@
3.4 from datetime import datetime
3.5 from imiptools.client import Client
3.6 from imiptools.data import get_uri, get_window_end, Object, uri_values
3.7 -from imiptools.dates import format_datetime, format_time
3.8 +from imiptools.dates import format_datetime, format_time, to_recurrence_start
3.9 from imiptools.period import FreeBusyPeriod, \
3.10 remove_period, remove_affected_period, update_freebusy
3.11 from imipweb.env import CGIEnvironment
3.12 @@ -202,7 +202,7 @@
3.13 # object.
3.14
3.15 for recurrenceid in self._get_recurrences(uid):
3.16 - remove_affected_period(freebusy, uid, recurrenceid)
3.17 + remove_affected_period(freebusy, uid, to_recurrence_start(recurrenceid))
3.18
3.19 self.store.set_freebusy(self.user, freebusy)
3.20 self.publish_freebusy(freebusy)