imip-agent

Changeset

854:aa8db311ced1
2015-10-16 Paul Boddie raw files shortlog changelog graph Consolidated attendee and recurrence removal logic.
imipweb/event.py (file)
     1.1 --- a/imipweb/event.py	Fri Oct 16 19:39:04 2015 +0200
     1.2 +++ b/imipweb/event.py	Fri Oct 16 19:44:50 2015 +0200
     1.3 @@ -63,7 +63,9 @@
     1.4          without notification.
     1.5          """
     1.6  
     1.7 -        return self.can_edit_recurrence(recurrence) and recurrence.origin != "RRULE"
     1.8 +        return self.can_change_object() and \
     1.9 +               (self.can_edit_recurrence(recurrence) or not self.is_organiser()) and \
    1.10 +               recurrence.origin != "RRULE"
    1.11  
    1.12      def can_edit_recurrence(self, recurrence):
    1.13  
    1.14 @@ -84,7 +86,8 @@
    1.15          notification.
    1.16          """
    1.17  
    1.18 -        return self.can_edit_attendee(attendee) or attendee == self.user and self.is_organiser()
    1.19 +        return self.can_change_object() and \
    1.20 +               (self.can_edit_attendee(attendee) or attendee == self.user and self.is_organiser())
    1.21  
    1.22      def can_edit_attendee(self, attendee):
    1.23  
    1.24 @@ -401,7 +404,7 @@
    1.25  
    1.26          # Permit organisers to remove attendees.
    1.27  
    1.28 -        if self.can_change_object() and (self.can_remove_attendee(attendee_uri) or self.is_organiser()):
    1.29 +        if self.can_remove_attendee(attendee_uri) or self.is_organiser():
    1.30  
    1.31              # Permit the removal of newly-added attendees.
    1.32  
    1.33 @@ -532,9 +535,7 @@
    1.34              # counter-proposal. Organisers may need to unschedule recurrences
    1.35              # instead.
    1.36  
    1.37 -            remove_type = self.can_change_object() and \
    1.38 -                          (self.can_remove_recurrence(period) or not self.is_organiser()) and \
    1.39 -                          "submit" or "checkbox"
    1.40 +            remove_type = self.can_remove_recurrence(period) and "submit" or "checkbox"
    1.41  
    1.42              self.control("recur-remove", remove_type, str(index),
    1.43                  str(index) in args.get("recur-remove", []),
    1.44 @@ -1183,7 +1184,7 @@
    1.45                  except (IndexError, ValueError):
    1.46                      continue
    1.47  
    1.48 -                if self.can_remove_recurrence(recurrence) or not self.is_organiser():
    1.49 +                if self.can_remove_recurrence(recurrence):
    1.50                      del recurrences[i]
    1.51                      correction += 1
    1.52                  else: