imip-agent

Changeset

485:ecc4e2d95646
2015-04-05 Paul Boddie raw files shortlog changelog graph 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.
imipweb/event.py (file)
     1.1 --- a/imipweb/event.py	Sun Apr 05 01:09:26 2015 +0200
     1.2 +++ b/imipweb/event.py	Sun Apr 05 15:20:33 2015 +0200
     1.3 @@ -127,7 +127,7 @@
     1.4                  # Obtain any participants and those to be removed.
     1.5  
     1.6                  attendees = self.get_attendees()
     1.7 -                removed = args.get("remove")
     1.8 +                removed = [attendees[int(i)] for i in args.get("remove", [])]
     1.9                  to_cancel = update_attendees(obj, attendees, removed)
    1.10  
    1.11              # Update attendee participation.
    1.12 @@ -456,14 +456,24 @@
    1.13          args = self.env.get_args()
    1.14  
    1.15          attendees = self.get_attendees()
    1.16 +        existing_attendees = self.get_existing_attendees(obj)
    1.17 +        sequence = obj.get_value("SEQUENCE")
    1.18  
    1.19          if args.has_key("add"):
    1.20              attendees.append("")
    1.21  
    1.22 +        # Only actually remove attendees if the event is unsent or if it is the
    1.23 +        # current user being removed.
    1.24 +
    1.25          if args.has_key("remove"):
    1.26 -            removed_attendee = args["remove"][0]
    1.27 -            if removed_attendee in attendees:
    1.28 -                attendees.remove(removed_attendee)
    1.29 +            for i in args["remove"]:
    1.30 +                attendee = attendees[int(i)]
    1.31 +                existing = attendee in existing_attendees
    1.32 +
    1.33 +                if attendee in attendees and \
    1.34 +                    (not existing or sequence is None or attendee == self.user):
    1.35 +
    1.36 +                    attendees.remove(attendee)
    1.37  
    1.38          return attendees
    1.39  
    1.40 @@ -674,12 +684,13 @@
    1.41  
    1.42          existing = attendee_attr is not None
    1.43          partstat = attendee_attr and attendee_attr.get("PARTSTAT")
    1.44 +        sequence = obj.get_value("SEQUENCE")
    1.45  
    1.46          page.td(class_="objectvalue")
    1.47  
    1.48          # Show a form control as organiser for new attendees.
    1.49  
    1.50 -        if self.is_organiser(obj) and not existing:
    1.51 +        if self.is_organiser(obj) and (not existing or sequence is None):
    1.52              page.input(name="attendee", type="value", value=attendee, size="40")
    1.53          else:
    1.54              page.input(name="attendee", type="hidden", value=attendee)
    1.55 @@ -707,9 +718,9 @@
    1.56  
    1.57              # Permit the removal of newly-added attendees.
    1.58  
    1.59 -            remove_type = (existing and attendee != self.user) and "checkbox" or "submit"
    1.60 +            remove_type = (not existing or sequence is None or attendee == self.user) and "submit" or "checkbox"
    1.61  
    1.62 -            self._control("remove", remove_type, attendee, attendee in args.get("remove", []), id="remove-%d" % i, class_="remove")
    1.63 +            self._control("remove", remove_type, str(i), str(i) in args.get("remove", []), id="remove-%d" % i, class_="remove")
    1.64  
    1.65              page.label("Remove", for_="remove-%d" % i, class_="remove")
    1.66              page.label("Uninvited", for_="remove-%d" % i, class_="removed")