1.1 --- a/imipweb/event.py Sat Sep 19 17:58:47 2015 +0200
1.2 +++ b/imipweb/event.py Sat Sep 19 22:09:25 2015 +0200
1.3 @@ -376,6 +376,27 @@
1.4
1.5 return ordered_attendees
1.6
1.7 + def can_remove_attendee(self, attendee):
1.8 +
1.9 + """
1.10 + Return whether 'attendee' can be removed from the current object without
1.11 + notification.
1.12 + """
1.13 +
1.14 + return self.can_edit_attendee(attendee) or attendee == self.user
1.15 +
1.16 + def can_edit_attendee(self, attendee):
1.17 +
1.18 + "Return whether 'attendee' can be edited by an organiser."
1.19 +
1.20 + return self.attendee_is_new(attendee) or not self.obj.is_shared()
1.21 +
1.22 + def attendee_is_new(self, attendee):
1.23 +
1.24 + "Return whether 'attendee' is new to the current object."
1.25 +
1.26 + return attendee not in self.get_stored_attendees()
1.27 +
1.28 def update_attendees_from_page(self):
1.29
1.30 "Add or remove attendees. This does not affect the stored object."
1.31 @@ -383,7 +404,6 @@
1.32 args = self.env.get_args()
1.33
1.34 attendees = self.get_attendees_from_page()
1.35 - existing_attendees = self.get_stored_attendees()
1.36
1.37 if args.has_key("add"):
1.38 attendees.append("")
1.39 @@ -400,9 +420,7 @@
1.40 except IndexError:
1.41 continue
1.42
1.43 - existing = attendee in existing_attendees
1.44 -
1.45 - if not existing or not self.obj.is_shared() or attendee == self.user:
1.46 + if self.can_remove_attendee(attendee):
1.47 attendees.remove(attendee)
1.48 else:
1.49 still_to_remove.append(i)
1.50 @@ -607,14 +625,13 @@
1.51 page = self.page
1.52 args = self.env.get_args()
1.53
1.54 - existing = attendee_attr is not None
1.55 partstat = attendee_attr and attendee_attr.get("PARTSTAT")
1.56
1.57 page.td(class_="objectvalue")
1.58
1.59 # Show a form control as organiser for new attendees.
1.60
1.61 - if self.is_organiser() and (not existing or not self.obj.is_shared()):
1.62 + if self.is_organiser() and self.can_edit_attendee(attendee):
1.63 self._control("attendee", "value", attendee, size="40")
1.64 else:
1.65 self._control("attendee", "hidden", attendee)
1.66 @@ -630,9 +647,12 @@
1.67 # button in order to refresh the page and show a control for
1.68 # the current user, if indicated.
1.69
1.70 - elif self.is_organiser() and not existing:
1.71 + elif self.is_organiser() and self.attendee_is_new(attendee):
1.72 self._control("partstat-refresh", "submit", "refresh", id="partstat-%d" % i, class_="refresh")
1.73 page.label(dict(self.partstat_items).get(partstat, ""), for_="partstat-%s" % i, class_="partstat")
1.74 +
1.75 + # Otherwise, just show a label with the participation status.
1.76 +
1.77 else:
1.78 page.span(dict(self.partstat_items).get(partstat, ""), class_="partstat")
1.79
1.80 @@ -642,7 +662,7 @@
1.81
1.82 # Permit the removal of newly-added attendees.
1.83
1.84 - remove_type = (not existing or not self.obj.is_shared() or attendee == self.user) and "submit" or "checkbox"
1.85 + remove_type = self.can_remove_attendee(attendee) and "submit" or "checkbox"
1.86 self._control("remove", remove_type, str(i), str(i) in args.get("remove", []), id="remove-%d" % i, class_="remove")
1.87
1.88 page.label("Remove", for_="remove-%d" % i, class_="remove")