# HG changeset patch # User Paul Boddie # Date 1438019631 -7200 # Node ID 8043ce2f967c1275eafdab047d21e77c84df3f0f # Parent 97857cfb6da586f6b63c382575d8133d9567afed Suppress conflict reports when periods reported for other participants are presumably associated with the current event. Provided a common method for the "initial load" test. diff -r 97857cfb6da5 -r 8043ce2f967c imipweb/event.py --- a/imipweb/event.py Mon Jul 27 19:52:03 2015 +0200 +++ b/imipweb/event.py Mon Jul 27 19:53:51 2015 +0200 @@ -291,10 +291,7 @@ return all_values def get_current_main_period(self, obj): - args = self.env.get_args() - initial_load = not args.has_key("editing") - - if initial_load or not self.is_organiser(obj): + if self.is_initial_load() or not self.is_organiser(obj): return self.get_existing_main_period(obj) else: return self.get_main_period() @@ -338,10 +335,7 @@ is in progress, using form data otherwise. """ - args = self.env.get_args() - initial_load = not args.has_key("editing") - - if initial_load or not self.is_organiser(obj): + if self.is_initial_load() or not self.is_organiser(obj): return self.get_existing_recurrences(obj) else: return self.get_recurrences() @@ -351,7 +345,7 @@ "Return recurrences computed using the given 'obj'." recurrences = [] - for period in obj.get_periods(self.get_tzid(), self.get_window_end()): + for period in self.get_periods(obj): if period.origin != "DTSTART": recurrences.append(period) return recurrences @@ -380,6 +374,12 @@ return periods + def is_initial_load(self): + + "Return whether the event is being loaded and shown for the first time." + + return not self.env.get_args().has_key("editing") + def get_current_attendees(self, obj): """ @@ -387,10 +387,7 @@ edited. """ - args = self.env.get_args() - initial_load = not args.has_key("editing") - - if initial_load or not self.is_organiser(obj): + if self.is_initial_load() or not self.is_organiser(obj): return self.get_existing_attendees(obj) else: return self.get_attendees() @@ -514,9 +511,7 @@ # Obtain basic event information, generating any necessary editing controls. - initial_load = not args.has_key("editing") - - if initial_load or not self.is_organiser(obj): + if self.is_initial_load() or not self.is_organiser(obj): attendees = self.get_existing_attendees(obj) else: attendees = self.update_attendees(obj) @@ -841,11 +836,12 @@ # Obtain the user's timezone. tzid = self.get_tzid() - periods = obj.get_periods(self.get_tzid(), self.get_window_end()) + periods = self.get_periods(obj) # Indicate whether there are conflicting events. conflicts = [] + attendee_map = uri_dict(obj.get_value_map("ATTENDEE")) for participant in self.get_current_attendees(obj): if participant == self.user: @@ -863,10 +859,21 @@ # Show any conflicts with periods of actual attendance. + participant_attr = attendee_map.get(participant) + partstat = participant_attr and participant_attr.get("PARTSTAT") + for p in have_conflict(freebusy, periods, True): if not recurrenceid and self.is_replaced(p, recurrenceids): continue - if (p.uid != uid or (recurrenceid and p.recurrenceid) and p.recurrenceid != recurrenceid) and p.transp != "ORG": + + if ( # Unidentified or different event + (p.uid != uid or recurrenceid and p.recurrenceid and p.recurrenceid != recurrenceid) and + # Different period or unclear participation with the same period + (p not in periods or not partstat in ("ACCEPTED", "TENTATIVE")) and + # Participant not limited to organising + p.transp != "ORG" + ): + conflicts.append(p) conflicts.sort()