Fix timezone handling for RSVP deadline validation

Updated the RSVP deadline validation to automatically assign UTC as the timezone if none is provided, ensuring consistency. This prevents errors and enforces proper timezone-aware datetime usage.
This commit is contained in:
2025-03-14 03:02:51 +01:00
parent 3e12a47e1d
commit e50fca4e77

View File

@@ -51,7 +51,7 @@ class EventBase(BaseModel):
def validate_rsvp_deadline(cls, v, values):
if v:
if not v.tzinfo:
raise ValueError("RSVP deadline must be timezone-aware")
v = v.replace(tzinfo=timezone.utc)
if 'event_date' in values.data:
if v > values.data['event_date']:
raise ValueError("RSVP deadline must be before event date")