# HG changeset patch # User Paul Boddie # Date 1443286787 -7200 # Node ID 71918675739f60a2d5578f2b084f9e5859b8c05f # Parent 26fd43fa7db389097524bfd4f3e2aa70166bb7ba Supported counter-proposals properly in the calendar view, showing all proposals and their periods for affected events. diff -r 26fd43fa7db3 -r 71918675739f imipweb/resource.py --- a/imipweb/resource.py Sat Sep 26 17:39:20 2015 +0200 +++ b/imipweb/resource.py Sat Sep 26 18:59:47 2015 +0200 @@ -125,11 +125,11 @@ else: return parts[:2] - def _get_object(self, uid, recurrenceid=None, section=None): - if self.objects.has_key((uid, recurrenceid, section)): - return self.objects[(uid, recurrenceid, section)] + def _get_object(self, uid, recurrenceid=None, section=None, username=None): + if self.objects.has_key((uid, recurrenceid, section, username)): + return self.objects[(uid, recurrenceid, section, username)] - obj = self.objects[(uid, recurrenceid, section)] = self.get_stored_object(uid, recurrenceid, section) + obj = self.objects[(uid, recurrenceid, section, username)] = self.get_stored_object(uid, recurrenceid, section, username) return obj def _get_recurrences(self, uid): @@ -156,15 +156,27 @@ summary = [] for uid, recurrenceid, request_type in self._get_requests(): - obj = self.get_stored_object(uid, recurrenceid) - if obj: - recurrenceids = self._get_active_recurrences(uid) + + # Obtain either normal objects or counter-proposals. + + if not request_type: + objs = [self._get_object(uid, recurrenceid)] + elif request_type == "COUNTER": + objs = [] + for attendee in self.store.get_counters(self.user, uid, recurrenceid): + objs.append(self._get_object(uid, recurrenceid, "counters", attendee)) - # Obtain only active periods, not those replaced by redefined - # recurrences, converting to free/busy periods. + # For each object, obtain the periods involved. + + for obj in objs: + if obj: + recurrenceids = self._get_active_recurrences(uid) - for p in obj.get_active_periods(recurrenceids, self.get_tzid(), self.get_window_end()): - summary.append(obj.get_freebusy_period(p)) + # Obtain only active periods, not those replaced by redefined + # recurrences, converting to free/busy periods. + + for p in obj.get_active_periods(recurrenceids, self.get_tzid(), self.get_window_end()): + summary.append(obj.get_freebusy_period(p)) return summary