Add start/end time fields to CalendarEvent (#28) (#29)
Unit Tests / test (push) Successful in 3s

## Summary
Closes #28.

- Add optional `start_time` / `end_time` (`TimeField`) on `CalendarEvent`
- Expose times in Django admin list + form
- Replace hardcoded calendar template times with `time_range_display`
- Add migration `0013` and unit coverage for time formatting

## Test plan
- [ ] `python manage.py migrate`
- [ ] `python manage.py test schasite.tests.CalendarEventTests`
- [ ] In admin, edit an event with start/end times and confirm calendar page shows them
- [ ] Confirm events without times hide the Time rowReviewed-on: #29
This commit was merged in pull request #29.
This commit is contained in:
2026-08-04 11:00:24 -07:00
parent 04c3ac913c
commit f37ff3e87b
6 changed files with 80 additions and 2 deletions
+17
View File
@@ -321,6 +321,23 @@ class CalendarEventTests(TestCase):
self.assertFalse(undated.past_event())
self.assertFalse(undated.future_event())
def test_time_range_display(self):
event = CalendarEvent.objects.create(
event_name="Timed Event",
start_time=datetime.time(11, 0),
end_time=datetime.time(15, 0),
)
self.assertEqual(event.time_range_display(), "11:00 AM - 3:00 PM")
start_only = CalendarEvent.objects.create(
event_name="Start Only",
start_time=datetime.time(9, 30),
)
self.assertEqual(start_only.time_range_display(), "9:30 AM")
no_time = CalendarEvent.objects.create(event_name="No Time")
self.assertEqual(no_time.time_range_display(), "")
def test_calendar_page_splits_past_and_future(self):
today = datetime.date.today()
CalendarEvent.objects.create(