1.1 --- a/imipweb/event.py Mon Jul 27 19:52:03 2015 +0200
1.2 +++ b/imipweb/event.py Mon Jul 27 19:53:51 2015 +0200
1.3 @@ -291,10 +291,7 @@
1.4 return all_values
1.5
1.6 def get_current_main_period(self, obj):
1.7 - args = self.env.get_args()
1.8 - initial_load = not args.has_key("editing")
1.9 -
1.10 - if initial_load or not self.is_organiser(obj):
1.11 + if self.is_initial_load() or not self.is_organiser(obj):
1.12 return self.get_existing_main_period(obj)
1.13 else:
1.14 return self.get_main_period()
1.15 @@ -338,10 +335,7 @@
1.16 is in progress, using form data otherwise.
1.17 """
1.18
1.19 - args = self.env.get_args()
1.20 - initial_load = not args.has_key("editing")
1.21 -
1.22 - if initial_load or not self.is_organiser(obj):
1.23 + if self.is_initial_load() or not self.is_organiser(obj):
1.24 return self.get_existing_recurrences(obj)
1.25 else:
1.26 return self.get_recurrences()
1.27 @@ -351,7 +345,7 @@
1.28 "Return recurrences computed using the given 'obj'."
1.29
1.30 recurrences = []
1.31 - for period in obj.get_periods(self.get_tzid(), self.get_window_end()):
1.32 + for period in self.get_periods(obj):
1.33 if period.origin != "DTSTART":
1.34 recurrences.append(period)
1.35 return recurrences
1.36 @@ -380,6 +374,12 @@
1.37
1.38 return periods
1.39
1.40 + def is_initial_load(self):
1.41 +
1.42 + "Return whether the event is being loaded and shown for the first time."
1.43 +
1.44 + return not self.env.get_args().has_key("editing")
1.45 +
1.46 def get_current_attendees(self, obj):
1.47
1.48 """
1.49 @@ -387,10 +387,7 @@
1.50 edited.
1.51 """
1.52
1.53 - args = self.env.get_args()
1.54 - initial_load = not args.has_key("editing")
1.55 -
1.56 - if initial_load or not self.is_organiser(obj):
1.57 + if self.is_initial_load() or not self.is_organiser(obj):
1.58 return self.get_existing_attendees(obj)
1.59 else:
1.60 return self.get_attendees()
1.61 @@ -514,9 +511,7 @@
1.62
1.63 # Obtain basic event information, generating any necessary editing controls.
1.64
1.65 - initial_load = not args.has_key("editing")
1.66 -
1.67 - if initial_load or not self.is_organiser(obj):
1.68 + if self.is_initial_load() or not self.is_organiser(obj):
1.69 attendees = self.get_existing_attendees(obj)
1.70 else:
1.71 attendees = self.update_attendees(obj)
1.72 @@ -841,11 +836,12 @@
1.73 # Obtain the user's timezone.
1.74
1.75 tzid = self.get_tzid()
1.76 - periods = obj.get_periods(self.get_tzid(), self.get_window_end())
1.77 + periods = self.get_periods(obj)
1.78
1.79 # Indicate whether there are conflicting events.
1.80
1.81 conflicts = []
1.82 + attendee_map = uri_dict(obj.get_value_map("ATTENDEE"))
1.83
1.84 for participant in self.get_current_attendees(obj):
1.85 if participant == self.user:
1.86 @@ -863,10 +859,21 @@
1.87
1.88 # Show any conflicts with periods of actual attendance.
1.89
1.90 + participant_attr = attendee_map.get(participant)
1.91 + partstat = participant_attr and participant_attr.get("PARTSTAT")
1.92 +
1.93 for p in have_conflict(freebusy, periods, True):
1.94 if not recurrenceid and self.is_replaced(p, recurrenceids):
1.95 continue
1.96 - if (p.uid != uid or (recurrenceid and p.recurrenceid) and p.recurrenceid != recurrenceid) and p.transp != "ORG":
1.97 +
1.98 + if ( # Unidentified or different event
1.99 + (p.uid != uid or recurrenceid and p.recurrenceid and p.recurrenceid != recurrenceid) and
1.100 + # Different period or unclear participation with the same period
1.101 + (p not in periods or not partstat in ("ACCEPTED", "TENTATIVE")) and
1.102 + # Participant not limited to organising
1.103 + p.transp != "ORG"
1.104 + ):
1.105 +
1.106 conflicts.append(p)
1.107
1.108 conflicts.sort()