imip-agent

Changeset

837:d220d0bbecdc
2015-10-14 Paul Boddie raw files shortlog changelog graph Present suggested attendees and periods only when new attendees and different periods are actually provided.
imipweb/event.py (file)
     1.1 --- a/imipweb/event.py	Wed Oct 14 18:00:04 2015 +0200
     1.2 +++ b/imipweb/event.py	Wed Oct 14 18:23:01 2015 +0200
     1.3 @@ -565,85 +565,89 @@
     1.4  
     1.5              # Get suggested periods.
     1.6  
     1.7 -            suggested_periods[attendee] = self.get_periods(obj)
     1.8 +            periods = self.get_periods(obj)
     1.9 +            if set(periods).difference(self.get_periods(self.obj)):
    1.10 +                suggested_periods[attendee] = periods
    1.11  
    1.12          # Present the suggested attendees.
    1.13  
    1.14 -        page.p("The following attendees have been suggested for this event:")
    1.15 +        if suggested_attendees:
    1.16 +            page.p("The following attendees have been suggested for this event:")
    1.17  
    1.18 -        page.table(cellspacing=5, cellpadding=5, class_="counters")
    1.19 -        page.thead()
    1.20 -        page.tr()
    1.21 -        page.th("Attendee")
    1.22 -        page.th("Suggested by...")
    1.23 -        page.tr.close()
    1.24 -        page.thead.close()
    1.25 -        page.tbody()
    1.26 +            page.table(cellspacing=5, cellpadding=5, class_="counters")
    1.27 +            page.thead()
    1.28 +            page.tr()
    1.29 +            page.th("Attendee")
    1.30 +            page.th("Suggested by...")
    1.31 +            page.tr.close()
    1.32 +            page.thead.close()
    1.33 +            page.tbody()
    1.34  
    1.35 -        suggested_attendees = list(suggested_attendees.items())
    1.36 -        suggested_attendees.sort()
    1.37 +            suggested_attendees = list(suggested_attendees.items())
    1.38 +            suggested_attendees.sort()
    1.39  
    1.40 -        for suggested, attendees in suggested_attendees:
    1.41 -            page.tr()
    1.42 -            page.td(suggested)
    1.43 -            page.td(", ".join(attendees))
    1.44 -            page.tr.close()
    1.45 +            for suggested, attendees in suggested_attendees:
    1.46 +                page.tr()
    1.47 +                page.td(suggested)
    1.48 +                page.td(", ".join(attendees))
    1.49 +                page.tr.close()
    1.50  
    1.51 -        page.tbody.close()
    1.52 -        page.table.close()
    1.53 +            page.tbody.close()
    1.54 +            page.table.close()
    1.55  
    1.56          # Present the suggested periods.
    1.57  
    1.58 -        page.p("The following periods have been suggested for this event:")
    1.59 +        if suggested_periods:
    1.60 +            page.p("The following periods have been suggested for this event:")
    1.61  
    1.62 -        page.table(cellspacing=5, cellpadding=5, class_="counters")
    1.63 -        page.thead()
    1.64 -        page.tr()
    1.65 -        page.th("Periods", colspan=2)
    1.66 -        page.th("Suggested by...", rowspan=2)
    1.67 -        page.tr.close()
    1.68 -        page.tr()
    1.69 -        page.th("Start")
    1.70 -        page.th("End")
    1.71 -        page.tr.close()
    1.72 -        page.thead.close()
    1.73 -        page.tbody()
    1.74 +            page.table(cellspacing=5, cellpadding=5, class_="counters")
    1.75 +            page.thead()
    1.76 +            page.tr()
    1.77 +            page.th("Periods", colspan=2)
    1.78 +            page.th("Suggested by...", rowspan=2)
    1.79 +            page.tr.close()
    1.80 +            page.tr()
    1.81 +            page.th("Start")
    1.82 +            page.th("End")
    1.83 +            page.tr.close()
    1.84 +            page.thead.close()
    1.85 +            page.tbody()
    1.86  
    1.87 -        suggested_periods = list(suggested_periods.items())
    1.88 -        suggested_periods.sort()
    1.89 +            suggested_periods = list(suggested_periods.items())
    1.90 +            suggested_periods.sort()
    1.91  
    1.92 -        for attendee, periods in suggested_periods:
    1.93 -            first = True
    1.94 -            for p in periods:
    1.95 -                identifier = "%s-%s" % (format_datetime(p.get_start_point()), format_datetime(p.get_end_point()))
    1.96 -                css = identifier == counter and "selected" or ""
    1.97 -                
    1.98 -                page.tr(class_=css)
    1.99 +            for attendee, periods in suggested_periods:
   1.100 +                first = True
   1.101 +                for p in periods:
   1.102 +                    identifier = "%s-%s" % (format_datetime(p.get_start_point()), format_datetime(p.get_end_point()))
   1.103 +                    css = identifier == counter and "selected" or ""
   1.104 +                    
   1.105 +                    page.tr(class_=css)
   1.106  
   1.107 -                start = self.format_datetime(to_timezone(p.get_start(), tzid), "long")
   1.108 -                end = self.format_datetime(to_timezone(p.get_end(), tzid), "long")
   1.109 +                    start = self.format_datetime(to_timezone(p.get_start(), tzid), "long")
   1.110 +                    end = self.format_datetime(to_timezone(p.get_end(), tzid), "long")
   1.111  
   1.112 -                # Show each period.
   1.113 +                    # Show each period.
   1.114  
   1.115 -                page.td(start)
   1.116 -                page.td(end)
   1.117 +                    page.td(start)
   1.118 +                    page.td(end)
   1.119  
   1.120 -                # Show attendees and controls alongside the first period in each
   1.121 -                # attendee's collection.
   1.122 +                    # Show attendees and controls alongside the first period in each
   1.123 +                    # attendee's collection.
   1.124  
   1.125 -                if first:
   1.126 -                    page.td(attendee, rowspan=len(periods))
   1.127 -                    page.td(rowspan=len(periods))
   1.128 -                    self.control("accept-%d" % i, "submit", "Accept")
   1.129 -                    self.control("decline-%d" % i, "submit", "Decline")
   1.130 -                    self.control("counter", "hidden", attendee)
   1.131 -                    page.td.close()
   1.132 +                    if first:
   1.133 +                        page.td(attendee, rowspan=len(periods))
   1.134 +                        page.td(rowspan=len(periods))
   1.135 +                        self.control("accept-%d" % i, "submit", "Accept")
   1.136 +                        self.control("decline-%d" % i, "submit", "Decline")
   1.137 +                        self.control("counter", "hidden", attendee)
   1.138 +                        page.td.close()
   1.139  
   1.140 -                page.tr.close()
   1.141 -                first = False
   1.142 +                    page.tr.close()
   1.143 +                    first = False
   1.144  
   1.145 -        page.tbody.close()
   1.146 -        page.table.close()
   1.147 +            page.tbody.close()
   1.148 +            page.table.close()
   1.149  
   1.150      def show_conflicting_events(self):
   1.151