Add start/end time fields to CalendarEvent.
CI / test (pull_request) Successful in 4s
Unit Tests / test (pull_request) Successful in 3s

Closes #28. Replace hardcoded calendar times with admin-editable
start_time/end_time so event cards show real schedules.
This commit is contained in:
2026-08-04 12:59:58 -05:00
parent 04c3ac913c
commit ac9330f366
6 changed files with 80 additions and 2 deletions
+15
View File
@@ -66,6 +66,8 @@ class CalendarEvent(TimeInfoBase):
event_name = models.CharField(max_length=256)
start_date = models.DateField(blank=True, null=True)
end_date = models.DateField(blank=True, null=True)
start_time = models.TimeField(blank=True, null=True)
end_time = models.TimeField(blank=True, null=True)
location_name = models.CharField(max_length=256, blank=True, null=True)
coordinator_email = models.EmailField(max_length=256, blank=True, null=True)
event_link_name = models.CharField(max_length=64, blank=True, null=True)
@@ -90,6 +92,19 @@ class CalendarEvent(TimeInfoBase):
def no_date(self):
return not self.has_date()
def time_range_display(self):
"""Format start/end times for templates, e.g. '11:00 AM - 3:00 PM'."""
from django.utils.formats import time_format
if not self.start_time and not self.end_time:
return ""
start = time_format(self.start_time, "g:i A") if self.start_time else ""
end = time_format(self.end_time, "g:i A") if self.end_time else ""
if start and end:
return f"{start} - {end}"
return start or end
class CalendarEventAddressModel(TimeInfoBase):
calendar_event = models.OneToOneField(CalendarEvent, on_delete=models.CASCADE)