# HG changeset patch # User Paul Boddie # Date 1427476543 -3600 # Node ID d345233e4b0613fff830fcc092f9c4e6e32f3a8f # Parent 33dfed39e49621ad0d125a9d97b8cd1a6e489d30 Fixed layout for events occurring at the same time as instant events. Removed period selection for instant event padding cells. diff -r 33dfed39e496 -r d345233e4b06 imipweb/calendar.py --- a/imipweb/calendar.py Fri Mar 27 17:35:05 2015 +0100 +++ b/imipweb/calendar.py Fri Mar 27 18:15:43 2015 +0100 @@ -28,7 +28,7 @@ from imiptools.period import add_day_start_points, add_empty_days, add_slots, \ convert_periods, get_freebusy_details, \ get_scale, get_slots, get_spans, partition_by_day, \ - POINT + POINT, REPEATED from imipweb.resource import Resource class CalendarPage(Resource): @@ -544,8 +544,6 @@ intervals = list(intervals) intervals.sort() - last = None - for (point, indicator), endpoint in intervals: continuation = point == get_start_of_day(point, tzid) @@ -566,14 +564,16 @@ css = " ".join([ "slot", - (have_active or indicator) and "busy" or have_active_request and "suggested" or "empty", + (have_active or indicator == REPEATED) and "busy" or have_active_request and "suggested" or "empty", continuation and "daystart" or "" ]) page.tr(class_=css) - page.th(class_="timeslot") if indicator == POINT: + page.th(class_="timeslot") self._time_point(point, endpoint) + else: + page.th() page.th.close() # Obtain slots for the time point from each group. @@ -586,9 +586,7 @@ # the colspan is adjusted to be 1, not 0. if not active: - page.td(class_="empty container", colspan=max(columns, 1)) - self._empty_slot(point, endpoint) - page.td.close() + self._empty_slot(point, endpoint, max(columns, 1), indicator) continue slots = slots.items() @@ -605,9 +603,7 @@ # Flush empty slots preceding this one. if empty: - page.td(class_="empty container", colspan=empty) - self._empty_slot(point, endpoint) - page.td.close() + self._empty_slot(point, endpoint, empty, indicator) empty = 0 start, end, uid, recurrenceid, summary, organiser, key = get_freebusy_details(t) @@ -615,8 +611,10 @@ # Produce a table cell only at the start of the period # or when continued at the start of a day. + # Points defining the ends of instant events should + # never define the start of new events. - if point == start or continuation: + if indicator == POINT and (point == start or continuation): has_continued = continuation and point != start will_continue = not ends_on_same_day(point, end, tzid) @@ -658,9 +656,7 @@ empty = columns - len(active) if empty: - page.td(class_="empty container", colspan=empty) - self._empty_slot(point, endpoint) - page.td.close() + self._empty_slot(point, endpoint, empty, indicator) page.tr.close() @@ -712,13 +708,20 @@ else: page.input(name="slot", type="checkbox", value=value, id=identifier, class_="newevent selector") - def _empty_slot(self, point, endpoint): + def _empty_slot(self, point, endpoint, colspan, indicator): - "Show an empty slot label for the given 'point' and 'endpoint'." + """ + Show an empty slot cell for the given 'point' and 'endpoint', with the + given 'colspan' and 'indicator' (0 as POINT or 1 as REPEATED) + configuring the cell's appearance. + """ page = self.page - value, identifier = self._slot_value_and_identifier(point, endpoint) - page.label("Select/deselect period", class_="newevent popup", for_=identifier) + page.td(class_="empty%s" % (indicator == POINT and " container" or ""), colspan=colspan) + if indicator == POINT: + value, identifier = self._slot_value_and_identifier(point, endpoint) + page.label("Select/deselect period", class_="newevent popup", for_=identifier) + page.td.close() def _day_value_and_identifier(self, day):