1.1 --- a/macros/EventAggregator.py Sun Nov 07 23:56:44 2010 +0100
1.2 +++ b/macros/EventAggregator.py Tue Nov 09 00:40:33 2010 +0100
1.3 @@ -75,7 +75,7 @@
1.4
1.5 return EventAggregatorSupport.getQualifiedParameterName(self.calendar_name, argname)
1.6
1.7 - def getMonthYearQueryString(self, argname, year_month, prefix=1):
1.8 + def getDateQueryString(self, argname, date, prefix=1):
1.9
1.10 """
1.11 Return a query string fragment for the given 'argname', referring to the
1.12 @@ -87,22 +87,24 @@
1.13 summary action.
1.14 """
1.15
1.16 - if year_month is not None:
1.17 - year, month = year_month.as_tuple()
1.18 - month_argname = "%s-month" % argname
1.19 - year_argname = "%s-year" % argname
1.20 - if prefix:
1.21 - month_argname = self.getQualifiedParameterName(month_argname)
1.22 - year_argname = self.getQualifiedParameterName(year_argname)
1.23 - return "%s=%s&%s=%s" % (month_argname, month, year_argname, year)
1.24 + suffixes = ["year", "month", "day"]
1.25 +
1.26 + if date is not None:
1.27 + args = []
1.28 + for suffix, value in zip(suffixes, date.as_tuple()):
1.29 + suffixed_argname = "%s-%s" % (argname, suffix)
1.30 + if prefix:
1.31 + suffixed_argname = self.getQualifiedParameterName(suffixed_argname)
1.32 + args.append("%s=%s" % (suffixed_argname, value))
1.33 + return "&".join(args)
1.34 else:
1.35 return ""
1.36
1.37 - def getMonthQueryString(self, argname, month, prefix=1):
1.38 + def getRawDateQueryString(self, argname, date, prefix=1):
1.39
1.40 """
1.41 Return a query string fragment for the given 'argname', referring to the
1.42 - month given by the specified 'month' value, appropriate for this
1.43 + date given by the specified 'date' value, appropriate for this
1.44 calendar.
1.45
1.46 If 'prefix' is specified and set to a false value, the parameters in the
1.47 @@ -110,10 +112,10 @@
1.48 summary action.
1.49 """
1.50
1.51 - if month is not None:
1.52 + if date is not None:
1.53 if prefix:
1.54 argname = self.getQualifiedParameterName(argname)
1.55 - return "%s=%s" % (argname, month)
1.56 + return "%s=%s" % (argname, date)
1.57 else:
1.58 return ""
1.59
1.60 @@ -126,8 +128,8 @@
1.61 """
1.62
1.63 return "%s&%s&%s=%s" % (
1.64 - self.getMonthQueryString("start", start),
1.65 - self.getMonthQueryString("end", end),
1.66 + self.getRawDateQueryString("start", start),
1.67 + self.getRawDateQueryString("end", end),
1.68 self.getQualifiedParameterName("mode"), mode or self.mode
1.69 )
1.70
1.71 @@ -156,8 +158,8 @@
1.72 )
1.73 download_all_link = download_dialogue_link + "&doit=1"
1.74 download_link = download_all_link + ("&%s&%s" % (
1.75 - self.getMonthYearQueryString("start", self.calendar_start, prefix=0),
1.76 - self.getMonthYearQueryString("end", self.calendar_end, prefix=0)
1.77 + self.getDateQueryString("start", self.calendar_start, prefix=0),
1.78 + self.getDateQueryString("end", self.calendar_end, prefix=0)
1.79 ))
1.80
1.81 # Subscription links just explicitly select the RSS format.
1.82 @@ -173,11 +175,11 @@
1.83
1.84 if self.raw_calendar_start:
1.85 period_limits.append("&%s" %
1.86 - self.getMonthQueryString("start", self.raw_calendar_start, prefix=0)
1.87 + self.getRawDateQueryString("start", self.raw_calendar_start, prefix=0)
1.88 )
1.89 if self.raw_calendar_end:
1.90 period_limits.append("&%s" %
1.91 - self.getMonthQueryString("end", self.raw_calendar_end, prefix=0)
1.92 + self.getRawDateQueryString("end", self.raw_calendar_end, prefix=0)
1.93 )
1.94
1.95 period_limits = "".join(period_limits)
1.96 @@ -498,19 +500,19 @@
1.97
1.98 # Visit each coverage span, presenting the events in the span.
1.99
1.100 - for coverage, events in week_slots[location]:
1.101 + for events in week_slots[location]:
1.102
1.103 # Output each set.
1.104
1.105 - output.append(self.writeWeekSlot(first_day, number_of_days, month, week_end, coverage, events))
1.106 + output.append(self.writeWeekSlot(first_day, number_of_days, month, week_end, events))
1.107
1.108 # Add a spacer.
1.109
1.110 - output.append(self.writeSpacer(first_day, number_of_days))
1.111 + output.append(self.writeWeekSpacer(first_day, number_of_days))
1.112
1.113 return "".join(output)
1.114
1.115 - def writeWeekSlot(self, first_day, number_of_days, month, week_end, coverage, events):
1.116 + def writeWeekSlot(self, first_day, number_of_days, month, week_end, events):
1.117 page = self.page
1.118 request = page.request
1.119 fmt = page.formatter
1.120 @@ -534,7 +536,7 @@
1.121
1.122 # Output the day.
1.123
1.124 - if date not in coverage:
1.125 + if date not in events:
1.126 output.append(fmt.table_cell(on=1,
1.127 attrs={"class" : "event-day-content event-day-empty", "colspan" : "3"}))
1.128
1.129 @@ -544,7 +546,7 @@
1.130 event_page = event.getPage()
1.131 event_details = event.getDetails()
1.132
1.133 - if not (event_details["start"] <= date <= event_details["end"]):
1.134 + if date not in event:
1.135 continue
1.136
1.137 # Get basic properties of the event.
1.138 @@ -718,7 +720,7 @@
1.139 output.append(fmt.table_row(on=0))
1.140 return "".join(output)
1.141
1.142 - def writeSpacer(self, first_day, number_of_days):
1.143 + def writeWeekSpacer(self, first_day, number_of_days):
1.144 page = self.page
1.145 fmt = page.formatter
1.146
1.147 @@ -759,6 +761,60 @@
1.148 output.append(fmt.table_row(on=0))
1.149 return "".join(output)
1.150
1.151 + def writeEmptyDay(self, date):
1.152 + page = self.page
1.153 + fmt = page.formatter
1.154 +
1.155 + output = []
1.156 + output.append(fmt.table_row(on=1))
1.157 +
1.158 + output.append(fmt.table_cell(on=1,
1.159 + attrs={"class" : "event-day-content event-day-empty"}))
1.160 +
1.161 + output.append(fmt.table_row(on=0))
1.162 + return "".join(output)
1.163 +
1.164 + def writeDaySlots(self, date, full_coverage, day_slots):
1.165 + page = self.page
1.166 + fmt = page.formatter
1.167 +
1.168 + output = []
1.169 +
1.170 + locations = day_slots.keys()
1.171 + locations.sort(EventAggregatorSupport.sort_none_first)
1.172 +
1.173 + # Traverse the time scale of the full coverage, visiting each slot to
1.174 + # determine whether it provides content for each period.
1.175 +
1.176 + scale = EventAggregatorSupport.getCoverageScale(full_coverage)
1.177 +
1.178 + for period in scale:
1.179 + start = period.start
1.180 +
1.181 + output.append(fmt.table_row(on=1))
1.182 + output.append(fmt.table_cell(on=1, attrs={"class" : "event-weekday-heading"}))
1.183 + output.append(fmt.text(str(start)))
1.184 + output.append(fmt.table_cell(on=0))
1.185 +
1.186 + # Visit each slot corresponding to a location (or no location).
1.187 +
1.188 + #for location in locations:
1.189 +
1.190 + # # Visit each coverage span, presenting the events in the span.
1.191 +
1.192 + # for events in day_slots[location]:
1.193 +
1.194 + # # Output each set.
1.195 +
1.196 + # output.append(self.writeDaySlot(day, events))
1.197 +
1.198 + output.append(fmt.table_row(on=0))
1.199 +
1.200 + return "".join(output)
1.201 +
1.202 + def writeDaySlot(self, date, events):
1.203 + pass
1.204 +
1.205 # HTML-related functions.
1.206
1.207 def getColour(s):
1.208 @@ -1159,7 +1215,17 @@
1.209 full_coverage, day_slots = EventAggregatorSupport.getCoverage(
1.210 date, date, shown_events.get(date, []))
1.211
1.212 - output.append(self.writeDayHeading(date))
1.213 + output.append(view.writeDayHeading(date))
1.214 +
1.215 + # Either generate empty days...
1.216 +
1.217 + if not day_slots:
1.218 + output.append(view.writeEmptyDay(date))
1.219 +
1.220 + # Or generate each set of scheduled events...
1.221 +
1.222 + else:
1.223 + output.append(view.writeDaySlots(date, full_coverage, day_slots))
1.224
1.225 # End of day.
1.226