1.1 --- a/imip_manager.py Fri Jan 30 16:13:25 2015 +0100
1.2 +++ b/imip_manager.py Fri Jan 30 16:15:11 2015 +0100
1.3 @@ -614,7 +614,7 @@
1.4 # Record the slots and all time points employed.
1.5
1.6 groups.append(slots)
1.7 - all_points.update([point for point, slot in slots])
1.8 + all_points.update([point for point, active in slots])
1.9
1.10 # Partition the groups into days.
1.11
1.12 @@ -638,7 +638,17 @@
1.13 partitioned = {}
1.14
1.15 for day, day_slots in partition_by_day(slots).items():
1.16 - columns = max(columns, max(map(lambda i: len(i[1]), day_slots)))
1.17 + intervals = []
1.18 + last = None
1.19 +
1.20 + for point, active in day_slots:
1.21 + columns = max(columns, len(active))
1.22 + if last:
1.23 + intervals.append((last, point))
1.24 + last = point
1.25 +
1.26 + if last:
1.27 + intervals.append((last, None))
1.28
1.29 if not days.has_key(day):
1.30 days[day] = set()
1.31 @@ -646,9 +656,11 @@
1.32 # Convert each partition to a mapping from points to active
1.33 # periods.
1.34
1.35 - day_slots = dict(day_slots)
1.36 - partitioned[day] = day_slots
1.37 - days[day].update(day_slots.keys())
1.38 + partitioned[day] = dict(day_slots)
1.39 +
1.40 + # Record the divisions or intervals within each day.
1.41 +
1.42 + days[day].update(intervals)
1.43
1.44 if group_type != "request" or columns:
1.45 group_columns.append(columns)
1.46 @@ -715,7 +727,7 @@
1.47
1.48 # Produce a heading and time points for each day.
1.49
1.50 - for day, points in all_days:
1.51 + for day, intervals in all_days:
1.52 page.thead()
1.53 page.tr()
1.54 page.th(class_="dayheading", colspan=all_columns+1)
1.55 @@ -727,13 +739,13 @@
1.56 groups_for_day = [partitioned.get(day) for partitioned in partitioned_groups]
1.57
1.58 page.tbody()
1.59 - self.show_calendar_points(points, groups_for_day, partitioned_group_types, group_columns)
1.60 + self.show_calendar_points(intervals, groups_for_day, partitioned_group_types, group_columns)
1.61 page.tbody.close()
1.62
1.63 - def show_calendar_points(self, points, groups, group_types, group_columns):
1.64 + def show_calendar_points(self, intervals, groups, group_types, group_columns):
1.65
1.66 """
1.67 - Show the time 'points' along with period information from the given
1.68 + Show the time 'intervals' along with period information from the given
1.69 'groups', having the indicated 'group_types', each with the number of
1.70 columns given by 'group_columns'.
1.71 """
1.72 @@ -742,15 +754,15 @@
1.73
1.74 # Produce a row for each time point.
1.75
1.76 - points = list(points)
1.77 - points.sort()
1.78 + intervals = list(intervals)
1.79 + intervals.sort()
1.80
1.81 - for point in points:
1.82 + for point, endpoint in intervals:
1.83 continuation = point == get_start_of_day(point)
1.84
1.85 page.tr()
1.86 page.th(class_="timeslot")
1.87 - self._time_point(point)
1.88 + self._time_point(point, endpoint)
1.89 page.th.close()
1.90
1.91 # Obtain slots for the time point from each group.
1.92 @@ -764,7 +776,7 @@
1.93
1.94 if not active:
1.95 page.td(class_="empty container", colspan=max(columns, 1))
1.96 - self._empty_slot(point)
1.97 + self._empty_slot(point, endpoint)
1.98 page.td.close()
1.99 continue
1.100
1.101 @@ -819,7 +831,7 @@
1.102 page.td.close()
1.103 else:
1.104 page.td(class_="empty container")
1.105 - self._empty_slot(point)
1.106 + self._empty_slot(point, endpoint)
1.107 page.td.close()
1.108
1.109 # Pad with empty columns.
1.110 @@ -828,21 +840,26 @@
1.111 while i > 0:
1.112 i -= 1
1.113 page.td(class_="empty container")
1.114 - self._empty_slot(point)
1.115 + self._empty_slot(point, endpoint)
1.116 page.td.close()
1.117
1.118 page.tr.close()
1.119
1.120 - def _time_point(self, point):
1.121 + def _time_point(self, point, endpoint):
1.122 + page = self.page
1.123 + value, identifier = self._slot_value_and_identifier(point, endpoint)
1.124 + page.input(name="start", type="radio", value=value, id=identifier, class_="newevent")
1.125 + page.label(self.format_time(point, "long"), class_="timepoint", for_=identifier)
1.126 +
1.127 + def _empty_slot(self, point, endpoint):
1.128 page = self.page
1.129 - pointstr = format_datetime(point)
1.130 - page.input(name="start", type="radio", value=pointstr, id="start-%s" % pointstr, class_="newevent")
1.131 - page.label(self.format_time(point, "long"), class_="timepoint", for_="start-%s" % pointstr)
1.132 + value, identifier = self._slot_value_and_identifier(point, endpoint)
1.133 + page.label("Make a new event in this period", class_="newevent popup", for_=identifier)
1.134
1.135 - def _empty_slot(self, point):
1.136 - page = self.page
1.137 - pointstr = format_datetime(point)
1.138 - page.label("Start a new event at this time", class_="newevent popup", for_="start-%s" % pointstr)
1.139 + def _slot_value_and_identifier(self, point, endpoint):
1.140 + value = "%s-%s" % tuple(map(format_datetime, [point, endpoint]))
1.141 + identifier = "slot-%s" % value
1.142 + return value, identifier
1.143
1.144 def select_action(self):
1.145