# HG changeset patch # User Paul Boddie # Date 1428240033 -7200 # Node ID ecc4e2d956460cf4f7b95973363bec77e519a24e # Parent f481451fb49520ad41699ebd3dce01006892ad64 Prevent the actual removal of existing attendees when editing continues, perhaps due to errors. Allow the editing and removal of unsent event attendees. Permit the removal of completely new attendees by changing the remove control values to indexes instead of the last-known handled attendee values. diff -r f481451fb495 -r ecc4e2d95646 imipweb/event.py --- a/imipweb/event.py Sun Apr 05 01:09:26 2015 +0200 +++ b/imipweb/event.py Sun Apr 05 15:20:33 2015 +0200 @@ -127,7 +127,7 @@ # Obtain any participants and those to be removed. attendees = self.get_attendees() - removed = args.get("remove") + removed = [attendees[int(i)] for i in args.get("remove", [])] to_cancel = update_attendees(obj, attendees, removed) # Update attendee participation. @@ -456,14 +456,24 @@ args = self.env.get_args() attendees = self.get_attendees() + existing_attendees = self.get_existing_attendees(obj) + sequence = obj.get_value("SEQUENCE") if args.has_key("add"): attendees.append("") + # Only actually remove attendees if the event is unsent or if it is the + # current user being removed. + if args.has_key("remove"): - removed_attendee = args["remove"][0] - if removed_attendee in attendees: - attendees.remove(removed_attendee) + for i in args["remove"]: + attendee = attendees[int(i)] + existing = attendee in existing_attendees + + if attendee in attendees and \ + (not existing or sequence is None or attendee == self.user): + + attendees.remove(attendee) return attendees @@ -674,12 +684,13 @@ existing = attendee_attr is not None partstat = attendee_attr and attendee_attr.get("PARTSTAT") + sequence = obj.get_value("SEQUENCE") page.td(class_="objectvalue") # Show a form control as organiser for new attendees. - if self.is_organiser(obj) and not existing: + if self.is_organiser(obj) and (not existing or sequence is None): page.input(name="attendee", type="value", value=attendee, size="40") else: page.input(name="attendee", type="hidden", value=attendee) @@ -707,9 +718,9 @@ # Permit the removal of newly-added attendees. - remove_type = (existing and attendee != self.user) and "checkbox" or "submit" + remove_type = (not existing or sequence is None or attendee == self.user) and "submit" or "checkbox" - self._control("remove", remove_type, attendee, attendee in args.get("remove", []), id="remove-%d" % i, class_="remove") + self._control("remove", remove_type, str(i), str(i) in args.get("remove", []), id="remove-%d" % i, class_="remove") page.label("Remove", for_="remove-%d" % i, class_="remove") page.label("Uninvited", for_="remove-%d" % i, class_="removed")