1.1 --- a/imiptools/dates.py Mon May 18 00:26:37 2015 +0200
1.2 +++ b/imiptools/dates.py Mon May 18 00:28:53 2015 +0200
1.3 @@ -431,7 +431,16 @@
1.4
1.5 return dtstart_attr and dtstart_attr.get("TZID") or dtend_attr and dtend_attr.get("TZID") or None
1.6
1.7 -def get_recurrence_start(recurrenceid, tzid):
1.8 +def get_recurrence_start(recurrenceid):
1.9 +
1.10 + """
1.11 + Return 'recurrenceid' in a form suitable for comparison with period start
1.12 + dates or datetimes.
1.13 + """
1.14 +
1.15 + return get_datetime(recurrenceid)
1.16 +
1.17 +def get_recurrence_start_point(recurrenceid, tzid):
1.18
1.19 """
1.20 Return 'recurrenceid' in a form suitable for comparison with free/busy start
1.21 @@ -440,13 +449,22 @@
1.22
1.23 return to_utc_datetime(get_datetime(recurrenceid), tzid)
1.24
1.25 -def to_recurrence_start(recurrenceid, tzid):
1.26 +def to_recurrence_start(recurrenceid):
1.27 +
1.28 + """
1.29 + Return 'recurrenceid' in a form suitable for use as an unambiguous
1.30 + identifier.
1.31 + """
1.32 +
1.33 + return format_datetime(get_recurrence_start(recurrenceid))
1.34 +
1.35 +def to_recurrence_start_point(recurrenceid, tzid):
1.36
1.37 """
1.38 Return 'recurrenceid' in a form suitable for use as an unambiguous
1.39 identifier, using 'tzid' to convert recurrence identifiers that are dates.
1.40 """
1.41
1.42 - return format_datetime(get_recurrence_start(recurrenceid, tzid))
1.43 + return format_datetime(get_recurrence_start_point(recurrenceid, tzid))
1.44
1.45 # vim: tabstop=4 expandtab shiftwidth=4
2.1 --- a/imiptools/handlers/__init__.py Mon May 18 00:26:37 2015 +0200
2.2 +++ b/imiptools/handlers/__init__.py Mon May 18 00:28:53 2015 +0200
2.3 @@ -26,7 +26,8 @@
2.4 from imiptools.data import Object, \
2.5 get_address, get_uri, get_value, \
2.6 is_new_object, uri_dict, uri_item, uri_values
2.7 -from imiptools.dates import format_datetime, to_recurrence_start, to_timezone
2.8 +from imiptools.dates import format_datetime, to_recurrence_start_point, \
2.9 + to_timezone
2.10 from imiptools.period import can_schedule, remove_period, \
2.11 remove_additional_periods, remove_affected_period, \
2.12 update_freebusy
2.13 @@ -120,18 +121,20 @@
2.14
2.15 # Convenience methods for modifying free/busy collections.
2.16
2.17 - def to_recurrence_start(self, recurrenceid):
2.18 + def to_recurrence_start_point(self, recurrenceid):
2.19
2.20 "Get 'recurrenceid' in a form suitable for matching free/busy entries."
2.21
2.22 - return to_recurrence_start(recurrenceid, self.get_tzid())
2.23 + tzid = self.obj.get_tzid() or self.get_tzid()
2.24 + return to_recurrence_start_point(recurrenceid, tzid)
2.25
2.26 def remove_from_freebusy(self, freebusy):
2.27
2.28 "Remove this event from the given 'freebusy' collection."
2.29
2.30 if not remove_period(freebusy, self.uid, self.recurrenceid) and self.recurrenceid:
2.31 - remove_affected_period(freebusy, self.uid, self.recurrenceid)
2.32 + tzid = self.obj.get_tzid() or self.get_tzid()
2.33 + remove_affected_period(freebusy, self.uid, self.to_recurrence_start_point(self.recurrenceid))
2.34
2.35 def remove_freebusy_for_recurrences(self, freebusy, recurrenceids=None):
2.36
2.37 @@ -144,7 +147,7 @@
2.38 """
2.39
2.40 if self.recurrenceid:
2.41 - recurrenceid = self.to_recurrence_start(self.recurrenceid)
2.42 + recurrenceid = self.to_recurrence_start_point(self.recurrenceid)
2.43 remove_affected_period(freebusy, self.uid, recurrenceid)
2.44 else:
2.45 # Remove obsolete recurrence periods.
2.46 @@ -155,7 +158,7 @@
2.47
2.48 if recurrenceids:
2.49 for recurrenceid in recurrenceids:
2.50 - recurrenceid = self.to_recurrence_start(recurrenceid)
2.51 + recurrenceid = self.to_recurrence_start_point(recurrenceid)
2.52 remove_affected_period(freebusy, self.uid, recurrenceid)
2.53
2.54 def _update_freebusy(self, freebusy, periods, recurrenceid, transp=None):
3.1 --- a/imipweb/handler.py Mon May 18 00:26:37 2015 +0200
3.2 +++ b/imipweb/handler.py Mon May 18 00:28:53 2015 +0200
3.3 @@ -159,7 +159,7 @@
3.4 for p in to_unschedule:
3.5 if not p.origin:
3.6 continue
3.7 - obj["RECURRENCE-ID"] = [(format_datetime(p.get_start_point()), {})]
3.8 + obj["RECURRENCE-ID"] = [(format_datetime(p.get_start()), {})]
3.9 parts.append(obj.to_part("CANCEL"))
3.10
3.11 # Send the updated event, along with a cancellation for each of the
4.1 --- a/imipweb/resource.py Mon May 18 00:26:37 2015 +0200
4.2 +++ b/imipweb/resource.py Mon May 18 00:28:53 2015 +0200
4.3 @@ -23,7 +23,7 @@
4.4 from imiptools.client import Client
4.5 from imiptools.data import get_uri, get_window_end, Object, uri_values
4.6 from imiptools.dates import format_datetime, format_time, get_recurrence_start, \
4.7 - to_recurrence_start
4.8 + get_recurrence_start_point, to_recurrence_start_point
4.9 from imiptools.period import FreeBusyPeriod, \
4.10 remove_period, remove_affected_period, update_freebusy
4.11 from imipweb.env import CGIEnvironment
4.12 @@ -149,7 +149,7 @@
4.13 recurrenceid,
4.14 obj.get_value("SUMMARY"),
4.15 obj.get_value("ORGANIZER"),
4.16 - self.get_tzid()
4.17 + p.get_tzid()
4.18 ))
4.19 return summary
4.20
4.21 @@ -157,16 +157,18 @@
4.22
4.23 def is_replaced(self, period, recurrenceids):
4.24 for s in recurrenceids:
4.25 - dt = get_recurrence_start(s, self.get_tzid())
4.26 - if period.get_start() == dt:
4.27 + d = get_recurrence_start(s)
4.28 + dt = get_recurrence_start_point(s, self.get_tzid())
4.29 + if period.get_start() == d or period.get_start_point() == dt:
4.30 return s
4.31 return None
4.32
4.33 def is_affected(self, period, recurrenceid):
4.34 if not recurrenceid:
4.35 return None
4.36 - dt = get_recurrence_start(recurrenceid, self.get_tzid())
4.37 - if period.get_start() == dt:
4.38 + d = get_recurrence_start(recurrenceid)
4.39 + dt = get_recurrence_start_point(recurrenceid, self.get_tzid())
4.40 + if period.get_start() == d or period.get_start_point() == dt:
4.41 return recurrenceid
4.42 return None
4.43
4.44 @@ -221,9 +223,10 @@
4.45
4.46 # Subtract any recurrences from the free/busy details of a parent
4.47 # object.
4.48 + # NOTE: The time zone may need obtaining using the object details.
4.49
4.50 for recurrenceid in self._get_recurrences(uid):
4.51 - remove_affected_period(freebusy, uid, to_recurrence_start(recurrenceid))
4.52 + remove_affected_period(freebusy, uid, to_recurrence_start_point(recurrenceid, self.get_tzid()))
4.53
4.54 self.store.set_freebusy(self.user, freebusy)
4.55 self.publish_freebusy(freebusy)