imip-agent

Change of imipweb/event.py

794:481df9da00f0
imipweb/event.py
     1.1 --- a/imipweb/event.py	Tue Sep 29 19:28:40 2015 +0200
     1.2 +++ b/imipweb/event.py	Tue Sep 29 21:03:03 2015 +0200
     1.3 @@ -19,7 +19,7 @@
     1.4  this program.  If not, see <http://www.gnu.org/licenses/>.
     1.5  """
     1.6  
     1.7 -from imiptools.data import get_uri, uri_dict, uri_items, uri_values
     1.8 +from imiptools.data import get_uri, get_verbose_address, uri_dict, uri_items, uri_values
     1.9  from imiptools.dates import format_datetime, to_timezone
    1.10  from imiptools.mail import Messenger
    1.11  from imiptools.period import have_conflict
    1.12 @@ -101,7 +101,7 @@
    1.13          return get_uri(self.obj.get_value("ORGANIZER")) == self.user
    1.14  
    1.15      def get_stored_attendees(self):
    1.16 -        return uri_values(self.obj.get_values("ATTENDEE") or [])
    1.17 +        return [get_verbose_address(value, attr) for value, attr in self.obj.get_items("ATTENDEE") or []]
    1.18  
    1.19      def get_stored_main_period(self):
    1.20  
    1.21 @@ -140,7 +140,7 @@
    1.22          page = self.page
    1.23          args = self.env.get_args()
    1.24  
    1.25 -        attendees = self.get_current_attendees()
    1.26 +        attendees = uri_values(self.get_current_attendees())
    1.27          is_attendee = self.user in attendees
    1.28          is_request = self._have_request(self.uid, self.recurrenceid)
    1.29  
    1.30 @@ -287,7 +287,7 @@
    1.31  
    1.32                      # Obtain details of attendees to supply attributes.
    1.33  
    1.34 -                    self.show_attendee(i, value, attendee_map.get(value))
    1.35 +                    self.show_attendee(i, value, attendee_map.get(get_uri(value)))
    1.36                      page.tr.close()
    1.37  
    1.38                  # Allow more attendees to be specified.
    1.39 @@ -314,7 +314,10 @@
    1.40                          first = False
    1.41  
    1.42                      page.td(class_="objectvalue %s" % field)
    1.43 -                    page.add(value)
    1.44 +                    if name == "ORGANIZER":
    1.45 +                        page.add(get_verbose_address(value, attr))
    1.46 +                    else:
    1.47 +                        page.add(value)
    1.48                      page.td.close()
    1.49                      page.tr.close()
    1.50  
    1.51 @@ -338,13 +341,14 @@
    1.52          page = self.page
    1.53          args = self.env.get_args()
    1.54  
    1.55 +        attendee_uri = get_uri(attendee)
    1.56          partstat = attendee_attr and attendee_attr.get("PARTSTAT")
    1.57  
    1.58          page.td(class_="objectvalue")
    1.59  
    1.60          # Show a form control as organiser for new attendees.
    1.61  
    1.62 -        if self.is_organiser() and self.can_edit_attendee(attendee):
    1.63 +        if self.is_organiser() and self.can_edit_attendee(attendee_uri):
    1.64              self.control("attendee", "value", attendee, size="40")
    1.65          else:
    1.66              self.control("attendee", "hidden", attendee)
    1.67 @@ -353,14 +357,14 @@
    1.68  
    1.69          # Show participation status, editable for the current user.
    1.70  
    1.71 -        if attendee == self.user:
    1.72 +        if attendee_uri == self.user:
    1.73              self.menu("partstat", partstat, self.partstat_items, "partstat")
    1.74  
    1.75          # Allow the participation indicator to act as a submit
    1.76          # button in order to refresh the page and show a control for
    1.77          # the current user, if indicated.
    1.78  
    1.79 -        elif self.is_organiser() and self.attendee_is_new(attendee):
    1.80 +        elif self.is_organiser() and self.attendee_is_new(attendee_uri):
    1.81              self.control("partstat-refresh", "submit", "refresh", id="partstat-%d" % i, class_="refresh")
    1.82              page.label(dict(self.partstat_items).get(partstat, ""), for_="partstat-%s" % i, class_="partstat")
    1.83  
    1.84 @@ -375,7 +379,7 @@
    1.85  
    1.86              # Permit the removal of newly-added attendees.
    1.87  
    1.88 -            remove_type = self.can_remove_attendee(attendee) and "submit" or "checkbox"
    1.89 +            remove_type = self.can_remove_attendee(attendee_uri) and "submit" or "checkbox"
    1.90              self.control("remove", remove_type, str(i), str(i) in args.get("remove", []), id="remove-%d" % i, class_="remove")
    1.91  
    1.92              page.label("Remove", for_="remove-%d" % i, class_="remove")
    1.93 @@ -751,7 +755,7 @@
    1.94  
    1.95                  # Obtain any participants and those to be removed.
    1.96  
    1.97 -                attendees = self.get_attendees_from_page()
    1.98 +                attendees = map(lambda s: s and get_uri(s), self.get_attendees_from_page())
    1.99                  removed = [attendees[int(i)] for i in args.get("remove", [])]
   1.100                  to_cancel = self.update_attendees(self.obj, attendees, removed)
   1.101                  single_user = not attendees or attendees == [self.user]
   1.102 @@ -921,19 +925,9 @@
   1.103  
   1.104      def get_attendees_from_page(self):
   1.105  
   1.106 -        """
   1.107 -        Return attendees from the request, normalised for iCalendar purposes.
   1.108 -        """
   1.109 -
   1.110 -        args = self.env.get_args()
   1.111 -        attendees = []
   1.112 +        "Return attendees from the request."
   1.113  
   1.114 -        for attendee in args.get("attendee", []):
   1.115 -            if attendee.strip():
   1.116 -                attendee = get_uri(attendee)
   1.117 -            attendees.append(attendee)
   1.118 -
   1.119 -        return attendees
   1.120 +        return self.env.get_args().get("attendee", [])
   1.121  
   1.122      def update_attendees_from_page(self):
   1.123