1.1 --- a/macros/EventAggregator.py Sat Apr 02 19:07:50 2011 +0200
1.2 +++ b/macros/EventAggregator.py Sun Apr 03 02:06:01 2011 +0200
1.3 @@ -9,11 +9,9 @@
1.4 """
1.5
1.6 from MoinMoin import wikiutil
1.7 -import EventAggregatorSupport
1.8 +from EventAggregatorSupport import *
1.9 import calendar
1.10
1.11 -linkToPage = EventAggregatorSupport.linkToPage
1.12 -
1.13 Dependencies = ['pages']
1.14
1.15 # Abstractions.
1.16 @@ -79,7 +77,7 @@
1.17
1.18 "Return the 'argname' qualified using the calendar name."
1.19
1.20 - return EventAggregatorSupport.getQualifiedParameterName(self.calendar_name, argname)
1.21 + return getQualifiedParameterName(self.calendar_name, argname)
1.22
1.23 def getDateQueryString(self, argname, date, prefix=1):
1.24
1.25 @@ -142,12 +140,12 @@
1.26 def getFullDateLabel(self, date):
1.27 page = self.page
1.28 request = page.request
1.29 - return EventAggregatorSupport.getFullDateLabel(request, date)
1.30 + return getFullDateLabel(request, date)
1.31
1.32 def getFullMonthLabel(self, year_month):
1.33 page = self.page
1.34 request = page.request
1.35 - return EventAggregatorSupport.getFullMonthLabel(request, year_month)
1.36 + return getFullMonthLabel(request, year_month)
1.37
1.38 def writeDownloadControls(self):
1.39
1.40 @@ -537,7 +535,7 @@
1.41
1.42 for weekday in range(0, 7):
1.43 output.append(fmt.table_cell(on=1, attrs={"class" : "event-weekday-heading", "colspan" : "3"}))
1.44 - output.append(fmt.text(_(EventAggregatorSupport.getDayLabel(weekday))))
1.45 + output.append(fmt.text(_(getDayLabel(weekday))))
1.46 output.append(fmt.table_cell(on=0))
1.47
1.48 output.append(fmt.table_row(on=0))
1.49 @@ -604,7 +602,7 @@
1.50 output = []
1.51
1.52 locations = week_slots.keys()
1.53 - locations.sort(EventAggregatorSupport.sort_none_first)
1.54 + locations.sort(sort_none_first)
1.55
1.56 # Visit each slot corresponding to a location (or no location).
1.57
1.58 @@ -859,12 +857,12 @@
1.59 output = []
1.60
1.61 locations = day_slots.keys()
1.62 - locations.sort(EventAggregatorSupport.sort_none_first)
1.63 + locations.sort(sort_none_first)
1.64
1.65 # Traverse the time scale of the full coverage, visiting each slot to
1.66 # determine whether it provides content for each period.
1.67
1.68 - scale = EventAggregatorSupport.getCoverageScale(full_coverage)
1.69 + scale = getCoverageScale(full_coverage)
1.70
1.71 # Define a mapping of events to rowspans.
1.72
1.73 @@ -1125,16 +1123,16 @@
1.74
1.75 # Find request parameters to override settings.
1.76
1.77 - mode = EventAggregatorSupport.getQualifiedParameter(request, calendar_name, "mode", mode or "calendar")
1.78 + mode = getQualifiedParameter(request, calendar_name, "mode", mode or "calendar")
1.79
1.80 # Different modes require different levels of precision.
1.81
1.82 if mode == "day":
1.83 - get_date = EventAggregatorSupport.getParameterDate
1.84 - get_form_date = EventAggregatorSupport.getFormDate
1.85 + get_date = getParameterDate
1.86 + get_form_date = getFormDate
1.87 else:
1.88 - get_date = EventAggregatorSupport.getParameterMonth
1.89 - get_form_date = EventAggregatorSupport.getFormMonth
1.90 + get_date = getParameterMonth
1.91 + get_form_date = getFormMonth
1.92
1.93 # Determine the limits of the calendar.
1.94
1.95 @@ -1146,13 +1144,18 @@
1.96
1.97 # Get the events according to the resolution of the calendar.
1.98
1.99 - events, shown_events, all_shown_events, earliest, latest = \
1.100 - EventAggregatorSupport.getEvents(request, category_names, calendar_start, calendar_end,
1.101 - mode == "day" and "date" or "month")
1.102 + resolution = mode == "day" and "date" or "month"
1.103 +
1.104 + event_pages = getPagesFromResults(getAllCategoryPages(category_names, request), request)
1.105 + events = getEventsFromPages(event_pages)
1.106 + calendar_period = getCalendarPeriod(calendar_start, calendar_end, resolution)
1.107 + all_shown_events = getEventsInPeriod(events, calendar_period, resolution)
1.108 +
1.109 + earliest, latest = all_shown_events.as_limits()
1.110
1.111 # Get a concrete period of time.
1.112
1.113 - first, last = EventAggregatorSupport.getConcretePeriod(calendar_start, calendar_end, earliest, latest)
1.114 + first, last = getConcretePeriod(calendar_start, calendar_end, earliest, latest)
1.115
1.116 # Define a view of the calendar, retaining useful navigational information.
1.117
1.118 @@ -1194,7 +1197,7 @@
1.119
1.120 # Get the events in order.
1.121
1.122 - ordered_events = EventAggregatorSupport.getOrderedEvents(all_shown_events)
1.123 + ordered_events = getOrderedEvents(all_shown_events)
1.124
1.125 # Show the events in order.
1.126
1.127 @@ -1304,8 +1307,8 @@
1.128 week_start = month.as_date(max(first_day, 1))
1.129 week_end = month.as_date(min(first_day + 6, number_of_days))
1.130
1.131 - full_coverage, week_slots = EventAggregatorSupport.getCoverage(
1.132 - week_start, week_end, shown_events.get(month, []))
1.133 + full_coverage, week_slots = getCoverage(
1.134 + all_shown_events.items_in_range(week_start, week_end.next_day()))
1.135
1.136 # Output a week, starting with the day numbers.
1.137
1.138 @@ -1349,7 +1352,8 @@
1.139
1.140 # Get the events in order.
1.141
1.142 - ordered_events = EventAggregatorSupport.getOrderedEvents(shown_events.get(month, []))
1.143 + ordered_events = getOrderedEvents(
1.144 + all_shown_events.items_in_range(month, month.next_month()))
1.145
1.146 # Show the events in order.
1.147
1.148 @@ -1418,11 +1422,11 @@
1.149
1.150 output.append(fmt.table(on=1, attrs={"tableclass" : "event-calendar-day"}))
1.151
1.152 - full_coverage, day_slots = EventAggregatorSupport.getCoverage(
1.153 - date, date, shown_events.get(date, []), "datetime")
1.154 + full_coverage, day_slots = getCoverage(
1.155 + all_shown_events.items_in_range(date, date.next_day()), "datetime")
1.156
1.157 # Work out how many columns the day title will need.
1.158 - # Includer spacers before each event column.
1.159 + # Include spacers before each event column.
1.160
1.161 colspan = sum(map(len, day_slots.values())) * 2 + 1
1.162