1.1 --- a/imipweb/resource.py Sun May 17 21:41:27 2015 +0200
1.2 +++ b/imipweb/resource.py Sun May 17 22:35:39 2015 +0200
1.3 @@ -22,7 +22,8 @@
1.4 from datetime import datetime
1.5 from imiptools.client import Client
1.6 from imiptools.data import get_uri, get_window_end, Object, uri_values
1.7 -from imiptools.dates import format_datetime, format_time, to_recurrence_start
1.8 +from imiptools.dates import format_datetime, format_time, get_recurrence_start, \
1.9 + to_recurrence_start
1.10 from imiptools.period import FreeBusyPeriod, \
1.11 remove_period, remove_affected_period, update_freebusy
1.12 from imipweb.env import CGIEnvironment
1.13 @@ -128,7 +129,7 @@
1.14 for uid, recurrenceid in self._get_requests():
1.15 obj = self._get_object(uid, recurrenceid)
1.16 if obj:
1.17 - periods = obj.get_periods_for_freebusy(self.get_tzid(), self.get_window_end())
1.18 + periods = obj.get_periods(self.get_tzid(), self.get_window_end())
1.19 recurrenceids = self._get_recurrences(uid)
1.20
1.21 # Convert the periods to more substantial free/busy items.
1.22 @@ -138,7 +139,7 @@
1.23 # Subtract any recurrences from the free/busy details of a
1.24 # parent object.
1.25
1.26 - if recurrenceid or p.start not in recurrenceids:
1.27 + if recurrenceid or not self.is_replaced(p, recurrenceids):
1.28 summary.append(
1.29 FreeBusyPeriod(
1.30 p.get_start(),
1.31 @@ -152,6 +153,23 @@
1.32 ))
1.33 return summary
1.34
1.35 + # Period and recurrence testing.
1.36 +
1.37 + def is_replaced(self, period, recurrenceids):
1.38 + for s in recurrenceids:
1.39 + dt = get_recurrence_start(s, self.get_tzid())
1.40 + if period.get_start() == dt:
1.41 + return s
1.42 + return None
1.43 +
1.44 + def is_affected(self, period, recurrenceid):
1.45 + if not recurrenceid:
1.46 + return None
1.47 + dt = get_recurrence_start(recurrenceid, self.get_tzid())
1.48 + if period.get_start() == dt:
1.49 + return recurrenceid
1.50 + return None
1.51 +
1.52 # Preference methods.
1.53
1.54 def get_user_locale(self):
1.55 @@ -195,7 +213,7 @@
1.56 freebusy = self.store.get_freebusy(self.user)
1.57
1.58 update_freebusy(freebusy,
1.59 - obj.get_periods_for_freebusy(self.get_tzid(), self.get_window_end()),
1.60 + obj.get_periods(self.get_tzid(), self.get_window_end()),
1.61 is_only_organiser and "ORG" or obj.get_value("TRANSP"),
1.62 uid, recurrenceid,
1.63 obj.get_value("SUMMARY"),