# HG changeset patch # User Paul Boddie # Date 1445812919 -3600 # Node ID d18ac1d27b581442d29a9a8af3ef63f0849b44a2 # Parent 842f578aba138b68b29ccf1c0eb3d5442656a213 Instead of filtering slots out, remove any end-of-period slots. diff -r 842f578aba13 -r d18ac1d27b58 imiptools/period.py --- a/imiptools/period.py Sun Oct 25 23:29:52 2015 +0100 +++ b/imiptools/period.py Sun Oct 25 23:41:59 2015 +0100 @@ -619,10 +619,10 @@ # Add a point and this event to the ending list. end = to_timezone(p.get_end(), tzid) - if not view_end or end < view_end: - if not scale.has_key(end): - scale[end] = [], [] - scale[end][1].append(p) + end = view_end and min(end, view_end) or end + if not scale.has_key(end): + scale[end] = [], [] + scale[end][1].append(p) return scale @@ -779,6 +779,19 @@ for t in new_slots: insort_left(slots, t) +def remove_end_slot(slots, view_period): + + """ + Remove from 'slots' any slot situated at the end of the given 'view_period'. + """ + + end = view_period.get_end_point() + if not end or not slots: + return + i = bisect_left(slots, (Point(end), None)) + if i < len(slots): + del slots[i:] + def add_slots(slots, points): """ diff -r 842f578aba13 -r d18ac1d27b58 imipweb/calendar.py --- a/imipweb/calendar.py Sun Oct 25 23:29:52 2015 +0100 +++ b/imipweb/calendar.py Sun Oct 25 23:41:59 2015 +0100 @@ -28,7 +28,7 @@ from imiptools.period import add_day_start_points, add_empty_days, add_slots, \ get_overlapping, \ get_scale, get_slots, get_spans, partition_by_day, \ - Period, Point + remove_end_slot, Period, Point from imipweb.resource import FormUtilities, ResourceClient class CalendarPage(ResourceClient, FormUtilities): @@ -487,6 +487,11 @@ add_day_start_points(slots, tzid) + # Remove the slot at the end of a view. + + if view_period: + remove_end_slot(slots, view_period) + # Record the slots and all time points employed. groups.append(slots)