# HG changeset patch # User Paul Boddie # Date 1395533721 -3600 # Node ID a1d7a02f19cb3ade6f30d210dc8f5b33f5a15237 # Parent 08edd667312226cdb70052884f9608ea75c71c5e Added period length restrictions on displayed calendars. diff -r 08edd6673122 -r a1d7a02f19cb EventAggregatorSupport/View.py --- a/EventAggregatorSupport/View.py Sun Mar 23 01:14:04 2014 +0100 +++ b/EventAggregatorSupport/View.py Sun Mar 23 01:15:21 2014 +0100 @@ -6,6 +6,7 @@ @license: GNU GPL (v2 or later), see COPYING.txt for details. """ +from DateSupport import Date from EventAggregatorSupport.Filter import getCalendarPeriod, getEventsInPeriod, \ getCoverage, getCoverageScale from EventAggregatorSupport.Locations import getMapsPage, getLocationsPage, Location @@ -140,7 +141,7 @@ self.first = first self.last = last - self.duration = abs(last - first) + 1 + self.initDuration() if self.calendar_name: @@ -156,6 +157,28 @@ self.previous_set_end = last.update(-self.duration) self.next_set_end = last.update(self.duration) + def initDuration(self): + + "Limit the duration of the calendar to prevent excessive output." + + request = self.page.request + + self.duration = abs(self.last - self.first) + 1 + + # Limit to the specified number of units. + + limit = int(getattr(request.cfg, "event_aggregator_max_duration", 20)) + + if self.duration > limit: + if isinstance(self.first, Date): + self.last = self.first.day_update(limit - 1) + else: + self.last = self.first.month_update(limit - 1) + + self.calendar_start = self.calendar_start or self.first + self.calendar_end = self.calendar_end or self.last + self.duration = limit + def getIdentifier(self): "Return a unique identifier to be used to refer to this view." diff -r 08edd6673122 -r a1d7a02f19cb TO_DO.txt --- a/TO_DO.txt Sun Mar 23 01:14:04 2014 +0100 +++ b/TO_DO.txt Sun Mar 23 01:15:21 2014 +0100 @@ -1,9 +1,3 @@ -View Extents ------------- - -It should not be possible for an event to provoke an undesirably large -calendar extent, thus creating work for the server and for browsers. - Navigation Controls -------------------