1.1 --- a/macros/EventAggregator.py Sun Aug 08 17:07:59 2010 +0200
1.2 +++ b/macros/EventAggregator.py Fri Oct 22 01:13:28 2010 +0200
1.3 @@ -623,7 +623,7 @@
1.4 week_start = month.as_date(max(first_day, 1))
1.5 week_end = month.as_date(min(first_day + 6, number_of_days))
1.6
1.7 - week_coverage, week_events = EventAggregatorSupport.getCoverage(
1.8 + full_coverage, week_slots = EventAggregatorSupport.getCoverage(
1.9 week_start, week_end, shown_events.get(month, []))
1.10
1.11 # Output a week, starting with the day numbers.
1.12 @@ -644,7 +644,7 @@
1.13 # Output normal days.
1.14
1.15 else:
1.16 - if date in week_coverage:
1.17 + if date in full_coverage:
1.18 output.append(fmt.table_cell(on=1,
1.19 attrs={"class" : "event-day-heading event-day-busy", "colspan" : "3"}))
1.20 else:
1.21 @@ -666,7 +666,7 @@
1.22
1.23 # Either generate empty days...
1.24
1.25 - if not week_events:
1.26 + if not week_slots:
1.27 output.append(fmt.table_row(on=1))
1.28
1.29 for weekday in range(0, 7):
1.30 @@ -690,228 +690,237 @@
1.31 # Or visit each set of scheduled events...
1.32
1.33 else:
1.34 - for coverage, events in week_events:
1.35 + locations = week_slots.keys()
1.36 + locations.sort(EventAggregatorSupport.sort_none_first)
1.37
1.38 - # Output each set.
1.39 -
1.40 - output.append(fmt.table_row(on=1))
1.41 + # Visit each slot corresponding to a location (or no location).
1.42
1.43 - # Then, output day details.
1.44 + for location in locations:
1.45 +
1.46 + # Visit each coverage span, presenting the events in the span.
1.47
1.48 - for weekday in range(0, 7):
1.49 - day = first_day + weekday
1.50 - date = month.as_date(day)
1.51 + for coverage, events in week_slots[location]:
1.52
1.53 - # Skip out-of-month days.
1.54 + # Output each set.
1.55
1.56 - if day < 1 or day > number_of_days:
1.57 - output.append(fmt.table_cell(on=1,
1.58 - attrs={"class" : "event-day-content event-day-excluded", "colspan" : "3"}))
1.59 - output.append(fmt.table_cell(on=0))
1.60 - continue
1.61 + output.append(fmt.table_row(on=1))
1.62
1.63 - # Output the day.
1.64 + # Then, output day details.
1.65
1.66 - if date not in coverage:
1.67 - output.append(fmt.table_cell(on=1,
1.68 - attrs={"class" : "event-day-content event-day-empty", "colspan" : "3"}))
1.69 -
1.70 - # Get event details for the current day.
1.71 + for weekday in range(0, 7):
1.72 + day = first_day + weekday
1.73 + date = month.as_date(day)
1.74
1.75 - for event in events:
1.76 - event_page = event.getPage()
1.77 - event_details = event.getDetails()
1.78 + # Skip out-of-month days.
1.79
1.80 - if not (event_details["start"] <= date <= event_details["end"]):
1.81 + if day < 1 or day > number_of_days:
1.82 + output.append(fmt.table_cell(on=1,
1.83 + attrs={"class" : "event-day-content event-day-excluded", "colspan" : "3"}))
1.84 + output.append(fmt.table_cell(on=0))
1.85 continue
1.86
1.87 - # Get basic properties of the event.
1.88 + # Output the day.
1.89 +
1.90 + if date not in coverage:
1.91 + output.append(fmt.table_cell(on=1,
1.92 + attrs={"class" : "event-day-content event-day-empty", "colspan" : "3"}))
1.93
1.94 - starts_today = event_details["start"] == date
1.95 - ends_today = event_details["end"] == date
1.96 - event_summary = event.getSummary(parent_name)
1.97 - is_ambiguous = event_details["start"].ambiguous() or event_details["end"].ambiguous()
1.98 + # Get event details for the current day.
1.99
1.100 - # Generate a colour for the event.
1.101 + for event in events:
1.102 + event_page = event.getPage()
1.103 + event_details = event.getDetails()
1.104
1.105 - bg = getColour(event_summary)
1.106 - fg = getBlackOrWhite(bg)
1.107 - style = ("background-color: rgb(%d, %d, %d); color: rgb(%d, %d, %d);" % (bg + fg))
1.108 + if not (event_details["start"] <= date <= event_details["end"]):
1.109 + continue
1.110
1.111 - # Determine if the event name should be shown.
1.112 + # Get basic properties of the event.
1.113
1.114 - start_of_period = starts_today or weekday == 0 or day == 1
1.115 + starts_today = event_details["start"] == date
1.116 + ends_today = event_details["end"] == date
1.117 + event_summary = event.getSummary(parent_name)
1.118 + is_ambiguous = event_details["start"].ambiguous() or event_details["end"].ambiguous()
1.119
1.120 - if name_usage == "daily" or start_of_period:
1.121 - hide_text = 0
1.122 - else:
1.123 - hide_text = 1
1.124 + # Generate a colour for the event.
1.125
1.126 - # Output start of day gap and determine whether
1.127 - # any event content should be explicitly output
1.128 - # for this day.
1.129 + bg = getColour(event_summary)
1.130 + fg = getBlackOrWhite(bg)
1.131 + style = ("background-color: rgb(%d, %d, %d); color: rgb(%d, %d, %d);" % (bg + fg))
1.132
1.133 - if starts_today:
1.134 + # Determine if the event name should be shown.
1.135
1.136 - # Single day events...
1.137 + start_of_period = starts_today or weekday == 0 or day == 1
1.138
1.139 - if ends_today:
1.140 - colspan = 3
1.141 - event_day_type = "event-day-single"
1.142 + if name_usage == "daily" or start_of_period:
1.143 + hide_text = 0
1.144 + else:
1.145 + hide_text = 1
1.146
1.147 - # Events starting today...
1.148 + # Output start of day gap and determine whether
1.149 + # any event content should be explicitly output
1.150 + # for this day.
1.151
1.152 - else:
1.153 - output.append(fmt.table_cell(on=1, attrs={"class" : "event-day-start-gap"}))
1.154 - output.append(fmt.table_cell(on=0))
1.155 + if starts_today:
1.156
1.157 - # Calculate the span of this cell.
1.158 - # Events whose names appear on every day...
1.159 + # Single day events...
1.160
1.161 - if name_usage == "daily":
1.162 - colspan = 2
1.163 - event_day_type = "event-day-starting"
1.164 + if ends_today:
1.165 + colspan = 3
1.166 + event_day_type = "event-day-single"
1.167
1.168 - # Events whose names appear once per week...
1.169 + # Events starting today...
1.170
1.171 else:
1.172 - if event_details["end"] <= week_end:
1.173 - event_length = event_details["end"].day() - day + 1
1.174 - colspan = (event_length - 2) * 3 + 4
1.175 + output.append(fmt.table_cell(on=1, attrs={"class" : "event-day-start-gap"}))
1.176 + output.append(fmt.table_cell(on=0))
1.177 +
1.178 + # Calculate the span of this cell.
1.179 + # Events whose names appear on every day...
1.180 +
1.181 + if name_usage == "daily":
1.182 + colspan = 2
1.183 + event_day_type = "event-day-starting"
1.184 +
1.185 + # Events whose names appear once per week...
1.186 +
1.187 else:
1.188 - event_length = week_end.day() - day + 1
1.189 - colspan = (event_length - 1) * 3 + 2
1.190 + if event_details["end"] <= week_end:
1.191 + event_length = event_details["end"].day() - day + 1
1.192 + colspan = (event_length - 2) * 3 + 4
1.193 + else:
1.194 + event_length = week_end.day() - day + 1
1.195 + colspan = (event_length - 1) * 3 + 2
1.196
1.197 - event_day_type = "event-day-multiple"
1.198 + event_day_type = "event-day-multiple"
1.199 +
1.200 + # Events continuing from a previous week...
1.201
1.202 - # Events continuing from a previous week...
1.203 + elif start_of_period:
1.204
1.205 - elif start_of_period:
1.206 + # End of continuing event...
1.207
1.208 - # End of continuing event...
1.209 + if ends_today:
1.210 + colspan = 2
1.211 + event_day_type = "event-day-ending"
1.212 +
1.213 + # Events continuing for at least one more day...
1.214 +
1.215 + else:
1.216
1.217 - if ends_today:
1.218 - colspan = 2
1.219 - event_day_type = "event-day-ending"
1.220 + # Calculate the span of this cell.
1.221 + # Events whose names appear on every day...
1.222 +
1.223 + if name_usage == "daily":
1.224 + colspan = 3
1.225 + event_day_type = "event-day-full"
1.226 +
1.227 + # Events whose names appear once per week...
1.228
1.229 - # Events continuing for at least one more day...
1.230 -
1.231 - else:
1.232 + else:
1.233 + if event_details["end"] <= week_end:
1.234 + event_length = event_details["end"].day() - day + 1
1.235 + colspan = (event_length - 1) * 3 + 2
1.236 + else:
1.237 + event_length = week_end.day() - day + 1
1.238 + colspan = event_length * 3
1.239
1.240 - # Calculate the span of this cell.
1.241 - # Events whose names appear on every day...
1.242 + event_day_type = "event-day-multiple"
1.243 +
1.244 + # Continuing events whose names appear on every day...
1.245
1.246 - if name_usage == "daily":
1.247 + elif name_usage == "daily":
1.248 + if ends_today:
1.249 + colspan = 2
1.250 + event_day_type = "event-day-ending"
1.251 + else:
1.252 colspan = 3
1.253 event_day_type = "event-day-full"
1.254
1.255 - # Events whose names appear once per week...
1.256 + # Continuing events whose names appear once per week...
1.257 +
1.258 + else:
1.259 + colspan = None
1.260
1.261 - else:
1.262 - if event_details["end"] <= week_end:
1.263 - event_length = event_details["end"].day() - day + 1
1.264 - colspan = (event_length - 1) * 3 + 2
1.265 - else:
1.266 - event_length = week_end.day() - day + 1
1.267 - colspan = event_length * 3
1.268 + # Output the main content only if it is not
1.269 + # continuing from a previous day.
1.270
1.271 - event_day_type = "event-day-multiple"
1.272 + if colspan is not None:
1.273
1.274 - # Continuing events whose names appear on every day...
1.275 + # Colour the cell for continuing events.
1.276
1.277 - elif name_usage == "daily":
1.278 - if ends_today:
1.279 - colspan = 2
1.280 - event_day_type = "event-day-ending"
1.281 - else:
1.282 - colspan = 3
1.283 - event_day_type = "event-day-full"
1.284 -
1.285 - # Continuing events whose names appear once per week...
1.286 + attrs={
1.287 + "class" : "event-day-content event-day-busy %s" % event_day_type,
1.288 + "colspan" : str(colspan)
1.289 + }
1.290
1.291 - else:
1.292 - colspan = None
1.293 + if not (starts_today and ends_today):
1.294 + attrs["style"] = style
1.295
1.296 - # Output the main content only if it is not
1.297 - # continuing from a previous day.
1.298 + output.append(fmt.table_cell(on=1, attrs=attrs))
1.299
1.300 - if colspan is not None:
1.301 + # Output the event.
1.302
1.303 - # Colour the cell for continuing events.
1.304 + if starts_today and ends_today or not hide_text:
1.305
1.306 - attrs={
1.307 - "class" : "event-day-content event-day-busy %s" % event_day_type,
1.308 - "colspan" : str(colspan)
1.309 - }
1.310 + # The event box contains the summary, alongside
1.311 + # other elements.
1.312
1.313 - if not (starts_today and ends_today):
1.314 - attrs["style"] = style
1.315 + output.append(fmt.div(on=1, css_class="event-summary-box"))
1.316 + output.append(fmt.div(on=1, css_class="event-summary", style=style))
1.317
1.318 - output.append(fmt.table_cell(on=1, attrs=attrs))
1.319 -
1.320 - # Output the event.
1.321 + if is_ambiguous:
1.322 + output.append(fmt.icon("/!\\"))
1.323
1.324 - if starts_today and ends_today or not hide_text:
1.325 -
1.326 - # The event box contains the summary, alongside
1.327 - # other elements.
1.328 + output.append(event_page.linkToPage(request, event_summary))
1.329 + output.append(fmt.div(on=0))
1.330
1.331 - output.append(fmt.div(on=1, css_class="event-summary-box"))
1.332 - output.append(fmt.div(on=1, css_class="event-summary", style=style))
1.333 + # Add a pop-up element for long summaries.
1.334
1.335 - if is_ambiguous:
1.336 - output.append(fmt.icon("/!\\"))
1.337 + output.append(fmt.div(on=1, css_class="event-summary-popup", style=style))
1.338
1.339 - output.append(event_page.linkToPage(request, event_summary))
1.340 - output.append(fmt.div(on=0))
1.341 + if is_ambiguous:
1.342 + output.append(fmt.icon("/!\\"))
1.343
1.344 - # Add a pop-up element for long summaries.
1.345 -
1.346 - output.append(fmt.div(on=1, css_class="event-summary-popup", style=style))
1.347 + output.append(event_page.linkToPage(request, event_summary))
1.348 + output.append(fmt.div(on=0))
1.349
1.350 - if is_ambiguous:
1.351 - output.append(fmt.icon("/!\\"))
1.352 + output.append(fmt.div(on=0))
1.353
1.354 - output.append(event_page.linkToPage(request, event_summary))
1.355 - output.append(fmt.div(on=0))
1.356 + # Output end of day content.
1.357
1.358 output.append(fmt.div(on=0))
1.359
1.360 - # Output end of day content.
1.361 + # Output end of day gap.
1.362
1.363 - output.append(fmt.div(on=0))
1.364 + if ends_today and not starts_today:
1.365 + output.append(fmt.table_cell(on=1, attrs={"class" : "event-day-end-gap"}))
1.366 + output.append(fmt.table_cell(on=0))
1.367
1.368 - # Output end of day gap.
1.369 + # End of day.
1.370
1.371 - if ends_today and not starts_today:
1.372 - output.append(fmt.table_cell(on=1, attrs={"class" : "event-day-end-gap"}))
1.373 - output.append(fmt.table_cell(on=0))
1.374 + output.append(fmt.table_cell(on=0))
1.375
1.376 - # End of day.
1.377 + # End of set.
1.378
1.379 - output.append(fmt.table_cell(on=0))
1.380 + output.append(fmt.table_row(on=0))
1.381
1.382 - # End of set.
1.383 -
1.384 - output.append(fmt.table_row(on=0))
1.385 + # Add a spacer.
1.386
1.387 - # Add a spacer.
1.388 -
1.389 - output.append(fmt.table_row(on=1))
1.390 + output.append(fmt.table_row(on=1))
1.391
1.392 - for weekday in range(0, 7):
1.393 - day = first_day + weekday
1.394 - css_classes = "event-day-spacer"
1.395 + for weekday in range(0, 7):
1.396 + day = first_day + weekday
1.397 + css_classes = "event-day-spacer"
1.398 +
1.399 + # Skip out-of-month days.
1.400
1.401 - # Skip out-of-month days.
1.402 -
1.403 - if day < 1 or day > number_of_days:
1.404 - css_classes += " event-day-excluded"
1.405 + if day < 1 or day > number_of_days:
1.406 + css_classes += " event-day-excluded"
1.407
1.408 - output.append(fmt.table_cell(on=1, attrs={"class" : css_classes, "colspan" : "3"}))
1.409 - output.append(fmt.table_cell(on=0))
1.410 + output.append(fmt.table_cell(on=1, attrs={"class" : css_classes, "colspan" : "3"}))
1.411 + output.append(fmt.table_cell(on=0))
1.412
1.413 - output.append(fmt.table_row(on=0))
1.414 + output.append(fmt.table_row(on=0))
1.415
1.416 # Process the next week...
1.417