1.1 --- a/imipweb/event.py Mon Oct 12 17:42:03 2015 +0200
1.2 +++ b/imipweb/event.py Mon Oct 12 23:53:38 2015 +0200
1.3 @@ -540,13 +540,66 @@
1.4
1.5 attendees = self.get_verbose_attendees(attendees)
1.6
1.7 - page.p("The following counter-proposals have been received for this event:")
1.8 + # Get suggestions. Attendees are aggregated and reference the existing
1.9 + # attendees suggesting them. Periods are referenced by each existing
1.10 + # attendee.
1.11 +
1.12 + suggested_attendees = {}
1.13 + suggested_periods = {}
1.14 +
1.15 + for i, attendee in enumerate(attendees):
1.16 + attendee_uri = get_uri(attendee)
1.17 + obj = self.get_stored_object(self.uid, self.recurrenceid, "counters", attendee_uri)
1.18 +
1.19 + # Get suggested attendees.
1.20 +
1.21 + for suggested_uri, suggested_attr in uri_dict(obj.get_value_map("ATTENDEE")).items():
1.22 + if suggested_uri == attendee_uri:
1.23 + continue
1.24 + suggested = get_verbose_address(suggested_uri, suggested_attr)
1.25 +
1.26 + if not suggested_attendees.has_key(suggested):
1.27 + suggested_attendees[suggested] = []
1.28 + suggested_attendees[suggested].append(attendee)
1.29 +
1.30 + # Get suggested periods.
1.31 +
1.32 + suggested_periods[attendee] = self.get_periods(obj)
1.33 +
1.34 + # Present the suggested attendees.
1.35 +
1.36 + page.p("The following attendees have been suggested for this event:")
1.37
1.38 page.table(cellspacing=5, cellpadding=5, class_="counters")
1.39 page.thead()
1.40 page.tr()
1.41 - page.th("Attendee", rowspan=2)
1.42 + page.th("Attendee")
1.43 + page.th("Suggested by...")
1.44 + page.tr.close()
1.45 + page.thead.close()
1.46 + page.tbody()
1.47 +
1.48 + suggested_attendees = list(suggested_attendees.items())
1.49 + suggested_attendees.sort()
1.50 +
1.51 + for suggested, attendees in suggested_attendees:
1.52 + page.tr()
1.53 + page.td(suggested)
1.54 + page.td(", ".join(attendees))
1.55 + page.tr.close()
1.56 +
1.57 + page.tbody.close()
1.58 + page.table.close()
1.59 +
1.60 + # Present the suggested periods.
1.61 +
1.62 + page.p("The following periods have been suggested for this event:")
1.63 +
1.64 + page.table(cellspacing=5, cellpadding=5, class_="counters")
1.65 + page.thead()
1.66 + page.tr()
1.67 page.th("Periods", colspan=2)
1.68 + page.th("Suggested by...", rowspan=2)
1.69 page.tr.close()
1.70 page.tr()
1.71 page.th("Start")
1.72 @@ -555,28 +608,30 @@
1.73 page.thead.close()
1.74 page.tbody()
1.75
1.76 - for i, attendee in enumerate(attendees):
1.77 - attendee_uri = get_uri(attendee)
1.78 - obj = self.get_stored_object(self.uid, self.recurrenceid, "counters", attendee_uri)
1.79 - periods = self.get_periods(obj)
1.80 + suggested_periods = list(suggested_periods.items())
1.81 + suggested_periods.sort()
1.82
1.83 + for attendee, periods in suggested_periods:
1.84 first = True
1.85 for p in periods:
1.86 identifier = "%s-%s" % (format_datetime(p.get_start_point()), format_datetime(p.get_end_point()))
1.87 css = identifier == counter and "selected" or ""
1.88 -
1.89 +
1.90 page.tr(class_=css)
1.91
1.92 - if first:
1.93 - page.td(attendee, rowspan=len(periods))
1.94 -
1.95 start = self.format_datetime(to_timezone(p.get_start(), tzid), "long")
1.96 end = self.format_datetime(to_timezone(p.get_end(), tzid), "long")
1.97
1.98 + # Show each period.
1.99 +
1.100 page.td(start)
1.101 page.td(end)
1.102
1.103 + # Show attendees and controls alongside the first period in each
1.104 + # attendee's collection.
1.105 +
1.106 if first:
1.107 + page.td(attendee, rowspan=len(periods))
1.108 page.td(rowspan=len(periods))
1.109 self.control("accept-%d" % i, "submit", "Accept")
1.110 self.control("decline-%d" % i, "submit", "Decline")