imip-agent

Change of imip_manager.py

171:b72619415ebf
imip_manager.py
     1.1 --- a/imip_manager.py	Sun Jan 25 00:55:38 2015 +0100
     1.2 +++ b/imip_manager.py	Sun Jan 25 00:56:53 2015 +0100
     1.3 @@ -451,7 +451,7 @@
     1.4                  if obj:
     1.5                      details = self._get_details(obj)
     1.6                      self.page.li()
     1.7 -                    self.page.a(get_value(details, "SUMMARY"), href="#%s" % request)
     1.8 +                    self.page.a(get_value(details, "SUMMARY"), href="#request-%s" % request)
     1.9                      self.page.li.close()
    1.10  
    1.11              self.page.ul.close()
    1.12 @@ -521,11 +521,12 @@
    1.13  
    1.14          groups = []
    1.15          group_columns = []
    1.16 +        group_types = []
    1.17          all_points = set()
    1.18  
    1.19          # Obtain time point information for each group of periods.
    1.20  
    1.21 -        for periods in [request_summary, freebusy]:
    1.22 +        for periods, group_type in zip([request_summary, freebusy], ["request", "freebusy"]):
    1.23              periods = convert_periods(periods, tzid)
    1.24  
    1.25              # Get the time scale with start and end points.
    1.26 @@ -543,14 +544,16 @@
    1.27              # Record the slots and all time points employed.
    1.28  
    1.29              groups.append(slots)
    1.30 +            group_types.append(group_type)
    1.31              all_points.update([point for point, slot in slots])
    1.32  
    1.33          # Partition the groups into days.
    1.34  
    1.35          days = {}
    1.36          partitioned_groups = []
    1.37 +        partitioned_group_types = []
    1.38  
    1.39 -        for slots in groups:
    1.40 +        for slots, group_type in zip(groups, group_types):
    1.41  
    1.42              # Propagate time points to all groups of time slots.
    1.43  
    1.44 @@ -578,14 +581,15 @@
    1.45                  days[day].update(day_slots.keys())
    1.46  
    1.47              if partitioned:
    1.48 -                group_columns.append(columns + 1)
    1.49 +                group_columns.append(columns)
    1.50                  partitioned_groups.append(partitioned)
    1.51 +                partitioned_group_types.append(group_type)
    1.52  
    1.53          page.table(border=1, cellspacing=0, cellpadding=5)
    1.54 -        self.show_calendar_days(days, partitioned_groups, group_columns)
    1.55 +        self.show_calendar_days(days, partitioned_groups, partitioned_group_types, group_columns)
    1.56          page.table.close()
    1.57  
    1.58 -    def show_calendar_days(self, days, partitioned_groups, group_columns):
    1.59 +    def show_calendar_days(self, days, partitioned_groups, partitioned_group_types, group_columns):
    1.60          page = self.page
    1.61  
    1.62          # Determine the number of columns required, the days providing time
    1.63 @@ -599,16 +603,16 @@
    1.64  
    1.65          for day, points in all_days:
    1.66              page.tr()
    1.67 -            page.th(class_="dayheading", colspan=all_columns)
    1.68 +            page.th(class_="dayheading", colspan=all_columns+1)
    1.69              page.add(self.format_date(day, "full"))
    1.70              page.th.close()
    1.71              page.tr.close()
    1.72  
    1.73              groups_for_day = [partitioned.get(day) for partitioned in partitioned_groups]
    1.74  
    1.75 -            self.show_calendar_points(points, groups_for_day, group_columns)
    1.76 +            self.show_calendar_points(points, groups_for_day, partitioned_group_types, group_columns)
    1.77  
    1.78 -    def show_calendar_points(self, points, groups, group_columns):
    1.79 +    def show_calendar_points(self, points, groups, group_types, group_columns):
    1.80          page = self.page
    1.81  
    1.82          # Produce a row for each time point.
    1.83 @@ -626,7 +630,7 @@
    1.84  
    1.85              # Obtain slots for the time point from each group.
    1.86  
    1.87 -            for columns, slots in zip(group_columns, groups):
    1.88 +            for columns, slots, group_type in zip(group_columns, groups, group_types):
    1.89                  active = slots and slots.get(point)
    1.90  
    1.91                  if not active:
    1.92 @@ -644,18 +648,34 @@
    1.93                      if t:
    1.94                          start, end, uid = t[:3]
    1.95                          span = spans[uid]
    1.96 +
    1.97 +                        # Produce a table cell only at the start of the period
    1.98 +                        # or when continued at the start of a day.
    1.99 +
   1.100                          if point == start or continuation:
   1.101  
   1.102                              page.td(class_="event", rowspan=span)
   1.103 +
   1.104                              obj = self._get_object(uid)
   1.105                              if obj:
   1.106                                  details = self._get_details(obj)
   1.107                                  summary = get_value(details, "SUMMARY")
   1.108 -                                href = "%s/%s" % (self.env.get_url().rstrip("/"), uid)
   1.109 -                                if point == start:
   1.110 -                                    page.a(summary, href=href, id=uid)
   1.111 +
   1.112 +                                # Only link to events if they are not being
   1.113 +                                # updated by requests.
   1.114 +
   1.115 +                                if uid in self._get_requests() and group_type != "request":
   1.116 +                                    page.span(summary, id="%s-%s" % (group_type, uid))
   1.117                                  else:
   1.118 -                                    page.a(summary, href=href)
   1.119 +                                    href = "%s/%s" % (self.env.get_url().rstrip("/"), uid)
   1.120 +
   1.121 +                                    # Only anchor the first cell of events.
   1.122 +
   1.123 +                                    if point == start:
   1.124 +                                        page.a(summary, href=href, id="%s-%s" % (group_type, uid))
   1.125 +                                    else:
   1.126 +                                        page.a(summary, href=href)
   1.127 +
   1.128                              page.td.close()
   1.129                      else:
   1.130                          page.td(class_="empty")