Make the management week calendar cover the full 24 hours
DEFAULT_DAY_START_HOUR/DEFAULT_DAY_END_HOUR only widened the grid's default 08:00-22:00 window for an event outside it, on whichever end that event fell on -- so a single early-morning event (e.g. one starting at midnight) widened the start but left the end clipped at 22:00 rather than covering the full day. Default the window to the full day (0-24) instead; the same expansion logic still guards a pathological almost-midnight-ending event, it just never needs to trigger anymore. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ECGMEwrc2k4D8VQuwjstj9
This commit is contained in:
@@ -19,10 +19,13 @@ import datetime
|
||||
|
||||
from django.utils import timezone
|
||||
|
||||
#: The week grid's default visible hours -- expanded automatically (see week_grid)
|
||||
#: if an event falls outside it, so nothing is ever clipped out of view.
|
||||
DEFAULT_DAY_START_HOUR = 8
|
||||
DEFAULT_DAY_END_HOUR = 22
|
||||
#: The week grid's visible hours -- the full day, always, so nothing is ever
|
||||
#: scrolled out of view regardless of what time events happen to fall at (this
|
||||
#: used to default to a narrower 08:00-22:00 window, only widening for events
|
||||
#: outside it -- a very early or very late one still left the grid clipped at
|
||||
#: the other end, e.g. midnight..22:00 rather than the full day).
|
||||
DEFAULT_DAY_START_HOUR = 0
|
||||
DEFAULT_DAY_END_HOUR = 24
|
||||
|
||||
#: Floor on a block's rendered height, in percent of the visible hour span -- a very
|
||||
#: short event (a 15-minute weigh-in) would otherwise render as a sliver too thin to
|
||||
|
||||
@@ -1388,27 +1388,28 @@ class CalendarGridTests(EventsTestBase):
|
||||
def test_add_months_rolls_over_the_year(self):
|
||||
self.assertEqual(add_months(date(2026, 11, 15), 2), date(2027, 1, 1))
|
||||
|
||||
def test_week_grid_places_an_event_within_the_default_hours(self):
|
||||
def test_week_grid_always_covers_the_full_day(self):
|
||||
monday = date(2026, 8, 17)
|
||||
event = self.make_event(start=self.at(monday, 10), end=self.at(monday, 11, 30))
|
||||
|
||||
grid = week_grid([event], monday)
|
||||
|
||||
self.assertEqual(grid["day_start_hour"], 8)
|
||||
self.assertEqual(grid["day_end_hour"], 22)
|
||||
span = 22 - 8
|
||||
self.assertEqual(grid["day_start_hour"], 0)
|
||||
self.assertEqual(grid["day_end_hour"], 24)
|
||||
self.assertEqual(grid["hours"], list(range(0, 25)))
|
||||
span = 24
|
||||
block = grid["days"][0]["blocks"][0]
|
||||
self.assertAlmostEqual(block["top_pct"], 100 * (10 - 8) / span, places=2)
|
||||
self.assertAlmostEqual(block["top_pct"], 100 * 10 / span, places=2)
|
||||
self.assertAlmostEqual(block["height_pct"], 100 * 1.5 / span, places=2)
|
||||
|
||||
def test_week_grid_expands_the_hours_for_an_early_or_late_event(self):
|
||||
def test_week_grid_still_covers_an_event_starting_at_midnight_or_ending_near_it(self):
|
||||
monday = date(2026, 8, 17)
|
||||
event = self.make_event(start=self.at(monday, 6), end=self.at(monday, 23))
|
||||
event = self.make_event(start=self.at(monday, 0), end=self.at(monday, 23, 45))
|
||||
|
||||
grid = week_grid([event], monday)
|
||||
|
||||
self.assertEqual(grid["day_start_hour"], 6)
|
||||
self.assertEqual(grid["day_end_hour"], 23)
|
||||
self.assertEqual(grid["day_start_hour"], 0)
|
||||
self.assertEqual(grid["day_end_hour"], 24)
|
||||
|
||||
def test_week_grid_excludes_events_outside_the_week(self):
|
||||
monday = date(2026, 8, 17)
|
||||
|
||||
Reference in New Issue
Block a user