1.1 --- a/EventAggregatorSupport/View.py Wed May 01 17:38:06 2013 +0200
1.2 +++ b/EventAggregatorSupport/View.py Fri May 03 16:37:36 2013 +0200
1.3 @@ -563,6 +563,8 @@
1.4 specific_start = self.calendar_start
1.5 specific_end = self.calendar_end
1.6
1.7 + multiday = self.resolution == "date" and len(specific_start.days_until(specific_end)) > 1
1.8 +
1.9 start = self.wider_calendar_start or self.original_calendar_start and specific_start
1.10 end = self.wider_calendar_end or self.original_calendar_end and specific_end
1.11
1.12 @@ -603,54 +605,60 @@
1.13 append(fmt.span(on=0))
1.14
1.15 if self.mode != "calendar":
1.16 - view_label = self.resolution == "date" and _("View day in calendar") or _("View as calendar")
1.17 + view_label = self.resolution == "date" and \
1.18 + (multiday and _("View days in calendar") or _("View day in calendar")) or \
1.19 + _("View as calendar")
1.20 append(fmt.span(on=1, css_class="event-view"))
1.21 append(linkToPage(request, page, view_label, calendar_link, onclick=calendar_update_link))
1.22 append(fmt.span(on=0))
1.23
1.24 if self.resolution == "date" and self.mode != "day":
1.25 + view_label = multiday and _("View days as calendar") or _("View day as calendar")
1.26 append(fmt.span(on=1, css_class="event-view"))
1.27 - append(linkToPage(request, page, _("View day as calendar"), specific_day_link, onclick=specific_day_update_link))
1.28 + append(linkToPage(request, page, view_label, specific_day_link, onclick=specific_day_update_link))
1.29 append(fmt.span(on=0))
1.30
1.31 if self.resolution != "date" and self.mode != "list" or self.resolution == "date":
1.32 - view_label = self.resolution == "date" and _("View day in list") or _("View as list")
1.33 + view_label = self.resolution == "date" and \
1.34 + (multiday and _("View days in list") or _("View day in list")) or \
1.35 + _("View as list")
1.36 append(fmt.span(on=1, css_class="event-view"))
1.37 append(linkToPage(request, page, view_label, list_link, onclick=list_update_link))
1.38 append(fmt.span(on=0))
1.39
1.40 if self.resolution == "date" and self.mode != "list":
1.41 + view_label = multiday and _("View days as list") or _("View day as list")
1.42 append(fmt.span(on=1, css_class="event-view"))
1.43 - append(linkToPage(request, page, _("View day as list"),
1.44 - specific_list_link, onclick=specific_list_update_link
1.45 - ))
1.46 + append(linkToPage(request, page, view_label, specific_list_link, onclick=specific_list_update_link))
1.47 append(fmt.span(on=0))
1.48
1.49 if self.resolution != "date" and self.mode != "table" or self.resolution == "date":
1.50 - view_label = self.resolution == "date" and _("View day in table") or _("View as table")
1.51 + view_label = self.resolution == "date" and \
1.52 + (multiday and _("View days in table") or _("View day in table")) or \
1.53 + _("View as table")
1.54 append(fmt.span(on=1, css_class="event-view"))
1.55 append(linkToPage(request, page, view_label, table_link, onclick=table_update_link))
1.56 append(fmt.span(on=0))
1.57
1.58 if self.resolution == "date" and self.mode != "table":
1.59 + view_label = multiday and _("View days as table") or _("View day as table")
1.60 append(fmt.span(on=1, css_class="event-view"))
1.61 - append(linkToPage(request, page, _("View day as table"),
1.62 - specific_table_link, onclick=specific_table_update_link
1.63 - ))
1.64 + append(linkToPage(request, page, view_label, specific_table_link, onclick=specific_table_update_link))
1.65 append(fmt.span(on=0))
1.66
1.67 if self.map_name:
1.68 if self.resolution != "date" and self.mode != "map" or self.resolution == "date":
1.69 - view_label = self.resolution == "date" and _("View day in map") or _("View as map")
1.70 + view_label = self.resolution == "date" and \
1.71 + (multiday and _("View days in map") or _("View day in map")) or \
1.72 + _("View as map")
1.73 append(fmt.span(on=1, css_class="event-view"))
1.74 append(linkToPage(request, page, view_label, map_link, onclick=map_update_link))
1.75 append(fmt.span(on=0))
1.76
1.77 if self.resolution == "date" and self.mode != "map":
1.78 + view_label = multiday and _("View days as map") or _("View day as map")
1.79 append(fmt.span(on=1, css_class="event-view"))
1.80 - append(linkToPage(request, page, _("View day as map"),
1.81 - specific_map_link, onclick=specific_map_update_link
1.82 - ))
1.83 + append(linkToPage(request, page, view_label, specific_map_link, onclick=specific_map_update_link))
1.84 append(fmt.span(on=0))
1.85
1.86 append(fmt.div(on=0))
1.87 @@ -1294,7 +1302,7 @@
1.88
1.89 day_rows = []
1.90
1.91 - for period in scale:
1.92 + for period, limit, times in scale:
1.93
1.94 # Ignore timespans before this day.
1.95
1.96 @@ -1318,7 +1326,7 @@
1.97 rowspans[event] += 1
1.98 day_row.append((location, event))
1.99
1.100 - day_rows.append((period, day_row))
1.101 + day_rows.append((period, day_row, times))
1.102
1.103 # Output the locations.
1.104
1.105 @@ -1345,23 +1353,21 @@
1.106
1.107 # Output the periods with event details.
1.108
1.109 - period = None
1.110 + last_period = period = None
1.111 events_written = set()
1.112
1.113 - for period, day_row in day_rows:
1.114 -
1.115 - # Write an empty heading for the start of the day where the first
1.116 - # applicable timespan starts before this day.
1.117 -
1.118 - if period.start < date:
1.119 - append(fmt.table_row(on=1))
1.120 - append(self.writeDayScaleHeading(""))
1.121 -
1.122 - # Otherwise, write a heading describing the time.
1.123 -
1.124 + for period, day_row, times in day_rows:
1.125 +
1.126 + # Write a heading describing the time.
1.127 +
1.128 + append(fmt.table_row(on=1))
1.129 +
1.130 + # Show times only for distinct periods.
1.131 +
1.132 + if not last_period or period.start != last_period.start:
1.133 + append(self.writeDayScaleHeading(times))
1.134 else:
1.135 - append(fmt.table_row(on=1))
1.136 - append(self.writeDayScaleHeading(period.start.time_string()))
1.137 + append(self.writeDayScaleHeading([]))
1.138
1.139 append(self.writeDaySpacer())
1.140
1.141 @@ -1382,12 +1388,14 @@
1.142
1.143 append(fmt.table_row(on=0))
1.144
1.145 + last_period = period
1.146 +
1.147 # Write a final time heading if the last period ends in the current day.
1.148
1.149 if period is not None:
1.150 if period.end == date:
1.151 append(fmt.table_row(on=1))
1.152 - append(self.writeDayScaleHeading(period.end.time_string()))
1.153 + append(self.writeDayScaleHeading(times))
1.154
1.155 for slot in day_row:
1.156 append(self.writeDaySpacer())
1.157 @@ -1397,7 +1405,7 @@
1.158
1.159 return "".join(output)
1.160
1.161 - def writeDayScaleHeading(self, heading):
1.162 + def writeDayScaleHeading(self, times):
1.163 page = self.page
1.164 fmt = page.request.formatter
1.165
1.166 @@ -1405,7 +1413,15 @@
1.167 append = output.append
1.168
1.169 append(fmt.table_cell(on=1, attrs={"class" : "event-scale-heading"}))
1.170 - append(fmt.text(heading))
1.171 +
1.172 + first = 1
1.173 + for t in times:
1.174 + if isinstance(t, DateTime):
1.175 + if not first:
1.176 + append(fmt.linebreak(0))
1.177 + append(fmt.text(t.time_string()))
1.178 + first = 0
1.179 +
1.180 append(fmt.table_cell(on=0))
1.181
1.182 return "".join(output)