Show in-progress multi-day events on the calendar (#33)
Unit Tests / test (push) Successful in 5s

## Summary
Closes #32.
- Keep an event on Upcoming until its end date is over. If `end_time` is set, it drops off once that time passes on the end date, so an in-progress multi-day event stays visible.
- Render the Past tab from `past_events` instead of `future_events`.
- Show the start–end date range when the dates differ.

## Test plan
- [ ] Multi-day event that started yesterday and ends tomorrow appears under Upcoming
- [ ] Event whose end time has already passed appears under Past
- [ ] Future single-day event still appears under Upcoming
- [ ] Past tab lists finished events only
- [ ] `uv run python manage.py test schasite.tests.CalendarEventTests`

Reviewed-on: #33
This commit was merged in pull request #33.
This commit is contained in:
westfarn committed 2026-10-06 11:41:16 -07:00
1 parent 531d97f3fc
commit 783712972b
3 files changed
+81 -15

No files matched your search

+21 -6
View File
@@ -77,17 +77,32 @@ class CalendarEvent(TimeInfoBase):
def has_date(self):
return not self.start_date is None
def _has_ended(self, now=None):
"""True once the event is over. In-progress multi-day events stay open
through end_date, and through end_time on that date when one is set.
"""
if not self.has_date():
return None
if now is None:
now = datetime.datetime.now()
end_date = self.end_date or self.start_date
if self.end_time:
return now >= datetime.datetime.combine(end_date, self.end_time)
return now.date() > end_date
def past_event(self):
if self.has_date():
return self.start_date <= datetime.datetime.now().date()
else:
ended = self._has_ended()
if ended is None:
return False
return ended
def future_event(self):
if self.has_date():
return self.start_date > datetime.datetime.now().date()
else:
"""Upcoming or currently in progress."""
ended = self._has_ended()
if ended is None:
return False
return not ended
def no_date(self):
return not self.has_date()