1.1 --- a/imipweb/calendar.py Fri Mar 27 18:23:41 2015 +0100
1.2 +++ b/imipweb/calendar.py Fri Mar 27 20:02:10 2015 +0100
1.3 @@ -28,7 +28,7 @@
1.4 from imiptools.period import add_day_start_points, add_empty_days, add_slots, \
1.5 convert_periods, get_freebusy_details, \
1.6 get_scale, get_slots, get_spans, partition_by_day, \
1.7 - POINT, REPEATED
1.8 + Point
1.9 from imipweb.resource import Resource
1.10
1.11 class CalendarPage(Resource):
1.12 @@ -371,15 +371,14 @@
1.13
1.14 last = None
1.15
1.16 - for point_details, active in day_slots:
1.17 - point, indicator = point_details
1.18 + for point, active in day_slots:
1.19 columns = max(columns, len(active))
1.20 - day_points[point_details] = active
1.21 + day_points[point] = active
1.22
1.23 if last:
1.24 intervals.append((last, point))
1.25
1.26 - last = point_details
1.27 + last = point
1.28
1.29 if last:
1.30 intervals.append((last, None))
1.31 @@ -544,8 +543,8 @@
1.32 intervals = list(intervals)
1.33 intervals.sort()
1.34
1.35 - for (point, indicator), endpoint in intervals:
1.36 - continuation = point == get_start_of_day(point, tzid)
1.37 + for point, endpoint in intervals:
1.38 + continuation = point.point == get_start_of_day(point.point, tzid)
1.39
1.40 # Some rows contain no period details and are marked as such.
1.41
1.42 @@ -553,7 +552,7 @@
1.43 have_active_request = False
1.44
1.45 for slots, group_type in zip(groups, group_types):
1.46 - if slots and slots.get((point, indicator)):
1.47 + if slots and slots.get(point):
1.48 if group_type == "request":
1.49 have_active_request = True
1.50 else:
1.51 @@ -564,12 +563,13 @@
1.52
1.53 css = " ".join([
1.54 "slot",
1.55 - (have_active or indicator == REPEATED) and "busy" or have_active_request and "suggested" or "empty",
1.56 + (have_active or point.indicator == Point.REPEATED) and "busy" or \
1.57 + have_active_request and "suggested" or "empty",
1.58 continuation and "daystart" or ""
1.59 ])
1.60
1.61 page.tr(class_=css)
1.62 - if indicator == POINT:
1.63 + if point.indicator == Point.PRINCIPAL:
1.64 page.th(class_="timeslot")
1.65 self._time_point(point, endpoint)
1.66 else:
1.67 @@ -579,14 +579,14 @@
1.68 # Obtain slots for the time point from each group.
1.69
1.70 for columns, slots, group_type in zip(group_columns, groups, group_types):
1.71 - active = slots and slots.get((point, indicator))
1.72 + active = slots and slots.get(point)
1.73
1.74 # Where no periods exist for the given time interval, generate
1.75 # an empty cell. Where a participant provides no periods at all,
1.76 # the colspan is adjusted to be 1, not 0.
1.77
1.78 if not active:
1.79 - self._empty_slot(point, endpoint, max(columns, 1), indicator)
1.80 + self._empty_slot(point, endpoint, max(columns, 1))
1.81 continue
1.82
1.83 slots = slots.items()
1.84 @@ -603,7 +603,7 @@
1.85 # Flush empty slots preceding this one.
1.86
1.87 if empty:
1.88 - self._empty_slot(point, endpoint, empty, indicator)
1.89 + self._empty_slot(point, endpoint, empty)
1.90 empty = 0
1.91
1.92 start, end, uid, recurrenceid, summary, organiser, key = get_freebusy_details(t)
1.93 @@ -614,10 +614,10 @@
1.94 # Points defining the ends of instant events should
1.95 # never define the start of new events.
1.96
1.97 - if indicator == POINT and (point == start or continuation):
1.98 + if point.indicator == Point.PRINCIPAL and (point.point == start or continuation):
1.99
1.100 - has_continued = continuation and point != start
1.101 - will_continue = not ends_on_same_day(point, end, tzid)
1.102 + has_continued = continuation and point.point != start
1.103 + will_continue = not ends_on_same_day(point.point, end, tzid)
1.104 is_organiser = organiser == self.user
1.105
1.106 css = " ".join([
1.107 @@ -633,7 +633,7 @@
1.108
1.109 html_id = "%s-%s-%s" % (group_type, uid, recurrenceid or "")
1.110
1.111 - if point == start and html_id not in self.html_ids:
1.112 + if point.point == start and html_id not in self.html_ids:
1.113 page.td(class_=css, rowspan=span, id=html_id)
1.114 self.html_ids.add(html_id)
1.115 else:
1.116 @@ -656,7 +656,7 @@
1.117 empty = columns - len(active)
1.118
1.119 if empty:
1.120 - self._empty_slot(point, endpoint, empty, indicator)
1.121 + self._empty_slot(point, endpoint, empty)
1.122
1.123 page.tr.close()
1.124
1.125 @@ -685,12 +685,12 @@
1.126
1.127 page = self.page
1.128 tzid = self.get_tzid()
1.129 - daystr = format_datetime(point.date())
1.130 + daystr = format_datetime(point.point.date())
1.131 value, identifier = self._slot_value_and_identifier(point, endpoint)
1.132 slots = self.env.get_args().get("slot", [])
1.133 self._slot_selector(value, identifier, slots)
1.134 - page.label(self.format_time(point, "long"), class_="timepoint day-%s" % daystr, for_=identifier)
1.135 - page.span(self.format_time(endpoint or get_end_of_day(point, tzid), "long"), class_="endpoint")
1.136 + page.label(self.format_time(point.point, "long"), class_="timepoint day-%s" % daystr, for_=identifier)
1.137 + page.span(self.format_time(endpoint and endpoint.point or get_end_of_day(point.point, tzid), "long"), class_="endpoint")
1.138
1.139 def _slot_selector(self, value, identifier, slots):
1.140
1.141 @@ -708,17 +708,16 @@
1.142 else:
1.143 page.input(name="slot", type="checkbox", value=value, id=identifier, class_="newevent selector")
1.144
1.145 - def _empty_slot(self, point, endpoint, colspan, indicator):
1.146 + def _empty_slot(self, point, endpoint, colspan):
1.147
1.148 """
1.149 Show an empty slot cell for the given 'point' and 'endpoint', with the
1.150 - given 'colspan' and 'indicator' (0 as POINT or 1 as REPEATED)
1.151 - configuring the cell's appearance.
1.152 + given 'colspan' configuring the cell's appearance.
1.153 """
1.154
1.155 page = self.page
1.156 - page.td(class_="empty%s" % (indicator == POINT and " container" or ""), colspan=colspan)
1.157 - if indicator == POINT:
1.158 + page.td(class_="empty%s" % (point.indicator == Point.PRINCIPAL and " container" or ""), colspan=colspan)
1.159 + if point.indicator == Point.PRINCIPAL:
1.160 value, identifier = self._slot_value_and_identifier(point, endpoint)
1.161 page.label("Select/deselect period", class_="newevent popup", for_=identifier)
1.162 page.td.close()
1.163 @@ -738,7 +737,7 @@
1.164 'endpoint'.
1.165 """
1.166
1.167 - value = "%s-%s" % (format_datetime(point), endpoint and format_datetime(endpoint) or "")
1.168 + value = "%s-%s" % (format_datetime(point.point), endpoint and format_datetime(endpoint.point) or "")
1.169 identifier = "slot-%s" % value
1.170 return value, identifier
1.171