1.1 --- a/imiptools/period.py Sun Oct 25 23:29:52 2015 +0100
1.2 +++ b/imiptools/period.py Sun Oct 25 23:41:59 2015 +0100
1.3 @@ -619,10 +619,10 @@
1.4 # Add a point and this event to the ending list.
1.5
1.6 end = to_timezone(p.get_end(), tzid)
1.7 - if not view_end or end < view_end:
1.8 - if not scale.has_key(end):
1.9 - scale[end] = [], []
1.10 - scale[end][1].append(p)
1.11 + end = view_end and min(end, view_end) or end
1.12 + if not scale.has_key(end):
1.13 + scale[end] = [], []
1.14 + scale[end][1].append(p)
1.15
1.16 return scale
1.17
1.18 @@ -779,6 +779,19 @@
1.19 for t in new_slots:
1.20 insort_left(slots, t)
1.21
1.22 +def remove_end_slot(slots, view_period):
1.23 +
1.24 + """
1.25 + Remove from 'slots' any slot situated at the end of the given 'view_period'.
1.26 + """
1.27 +
1.28 + end = view_period.get_end_point()
1.29 + if not end or not slots:
1.30 + return
1.31 + i = bisect_left(slots, (Point(end), None))
1.32 + if i < len(slots):
1.33 + del slots[i:]
1.34 +
1.35 def add_slots(slots, points):
1.36
1.37 """
2.1 --- a/imipweb/calendar.py Sun Oct 25 23:29:52 2015 +0100
2.2 +++ b/imipweb/calendar.py Sun Oct 25 23:41:59 2015 +0100
2.3 @@ -28,7 +28,7 @@
2.4 from imiptools.period import add_day_start_points, add_empty_days, add_slots, \
2.5 get_overlapping, \
2.6 get_scale, get_slots, get_spans, partition_by_day, \
2.7 - Period, Point
2.8 + remove_end_slot, Period, Point
2.9 from imipweb.resource import FormUtilities, ResourceClient
2.10
2.11 class CalendarPage(ResourceClient, FormUtilities):
2.12 @@ -487,6 +487,11 @@
2.13
2.14 add_day_start_points(slots, tzid)
2.15
2.16 + # Remove the slot at the end of a view.
2.17 +
2.18 + if view_period:
2.19 + remove_end_slot(slots, view_period)
2.20 +
2.21 # Record the slots and all time points employed.
2.22
2.23 groups.append(slots)