1.1 --- a/imipweb/calendar.py Sun Oct 18 18:02:07 2015 +0200
1.2 +++ b/imipweb/calendar.py Sun Oct 18 19:33:04 2015 +0200
1.3 @@ -26,7 +26,9 @@
1.4 get_start_of_next_day, get_timestamp, ends_on_same_day, \
1.5 to_timezone
1.6 from imiptools.period import add_day_start_points, add_empty_days, add_slots, \
1.7 - get_scale, get_slots, get_spans, partition_by_day, Point
1.8 + get_overlapping, \
1.9 + get_scale, get_slots, get_spans, partition_by_day, \
1.10 + Period, Point
1.11 from imipweb.resource import ResourceClient
1.12
1.13 class CalendarPage(ResourceClient):
1.14 @@ -278,7 +280,12 @@
1.15 tzid = self.get_tzid()
1.16
1.17 # Day view: start at the earliest known day and produce days until the
1.18 - # latest known day, perhaps with expandable sections of empty days.
1.19 + # latest known day, with expandable sections of empty days.
1.20 +
1.21 + args = self.env.get_query()
1.22 + view_start = self.get_date_arg(args, "start")
1.23 + view_end = self.get_date_arg(args, "end")
1.24 + view_period = (view_start or view_end) and Period(view_start, view_end, self.get_tzid())
1.25
1.26 # Requests are listed and linked to their tentative positions in the
1.27 # calendar. Other participants are also shown.
1.28 @@ -304,6 +311,11 @@
1.29
1.30 for periods in period_groups:
1.31
1.32 + # Filter periods outside the given view.
1.33 +
1.34 + if view_period:
1.35 + periods = get_overlapping(periods, view_period)
1.36 +
1.37 # Get the time scale with start and end points.
1.38
1.39 scale = get_scale(periods, tzid)
1.40 @@ -861,4 +873,10 @@
1.41 def _period_identifier(self, period):
1.42 return "%s-%s" % (format_datetime(period.get_start()), format_datetime(period.get_end()))
1.43
1.44 + def get_date_arg(self, args, name):
1.45 + values = args.get(name)
1.46 + if not values:
1.47 + return None
1.48 + return get_datetime(values[0], {"VALUE-TYPE" : "DATE"})
1.49 +
1.50 # vim: tabstop=4 expandtab shiftwidth=4