imip-agent

Changeset

795:1f8d646247f4
2015-09-29 Paul Boddie raw files shortlog changelog graph Fixed attendee removal and controls for removal.
imipweb/event.py (file)
     1.1 --- a/imipweb/event.py	Tue Sep 29 21:03:03 2015 +0200
     1.2 +++ b/imipweb/event.py	Tue Sep 29 23:26:49 2015 +0200
     1.3 @@ -93,7 +93,7 @@
     1.4  
     1.5          "Return whether 'attendee' is new to the current object."
     1.6  
     1.7 -        return attendee not in self.get_stored_attendees()
     1.8 +        return attendee not in uri_values(self.get_stored_attendees())
     1.9  
    1.10      # Access to stored object information.
    1.11  
    1.12 @@ -945,17 +945,20 @@
    1.13  
    1.14          if args.has_key("remove"):
    1.15              still_to_remove = []
    1.16 +            correction = 0
    1.17  
    1.18              for i in args["remove"]:
    1.19                  try:
    1.20 -                    attendee = attendees[int(i)]
    1.21 -                except IndexError:
    1.22 +                    i = int(i) - correction
    1.23 +                    attendee = attendees[i]
    1.24 +                except (IndexError, ValueError):
    1.25                      continue
    1.26  
    1.27 -                if self.can_remove_attendee(attendee):
    1.28 -                    attendees.remove(attendee)
    1.29 +                if self.can_remove_attendee(get_uri(attendee)):
    1.30 +                    del attendees[i]
    1.31 +                    correction += 1
    1.32                  else:
    1.33 -                    still_to_remove.append(i)
    1.34 +                    still_to_remove.append(str(i))
    1.35  
    1.36              args["remove"] = still_to_remove
    1.37  
    1.38 @@ -977,17 +980,20 @@
    1.39  
    1.40          if args.has_key("recur-remove"):
    1.41              still_to_remove = []
    1.42 +            correction = 0
    1.43  
    1.44              for i in args["recur-remove"]:
    1.45                  try:
    1.46 -                    recurrence = recurrences[int(i)]
    1.47 -                except IndexError:
    1.48 +                    i = int(i) - correction
    1.49 +                    recurrence = recurrences[i]
    1.50 +                except (IndexError, ValueError):
    1.51                      continue
    1.52  
    1.53                  if self.can_remove_recurrence(recurrence):
    1.54 -                    recurrences.remove(recurrence)
    1.55 +                    del recurrences[i]
    1.56 +                    correction += 1
    1.57                  else:
    1.58 -                    still_to_remove.append(i)
    1.59 +                    still_to_remove.append(str(i))
    1.60  
    1.61              args["recur-remove"] = still_to_remove
    1.62