feat: derive event lifecycle status from dates and flags

Replace persisted event statuses with publication and cancellation flags, and compute public lifecycle labels from event timing and registration capacity. Keep filters, registration checks, and profile responses aligned with the derived status.
This commit is contained in:
2026-10-03 12:46:16 +03:30
parent f268c9b88a
commit 6c5fadef2f
26 changed files with 525 additions and 178 deletions

View File

@@ -315,6 +315,15 @@ class PublicProfileEventSchema(Schema):
title: str
slug: str
start_time: datetime
end_time: datetime
registration_start_date: Optional[datetime] = None
registration_end_date: Optional[datetime] = None
effective_registration_end_date: datetime
capacity: Optional[int] = None
registration_count: int = 0
status: str
status_label: str
is_cancelled: bool = False
image_url: Optional[str] = None
participation: Literal["confirmed", "attended"]

View File

@@ -400,7 +400,7 @@ def get_public_profile(request, username: str):
Registration.objects.filter(
user=user,
event__is_deleted=False,
event__status__in=[Event.StatusChoices.PUBLISHED, Event.StatusChoices.COMPLETED],
event__is_published=True,
status__in=[Registration.StatusChoices.CONFIRMED, Registration.StatusChoices.ATTENDED],
)
.select_related("event")
@@ -412,6 +412,15 @@ def get_public_profile(request, username: str):
"title": event.title,
"slug": event.slug,
"start_time": event.start_time,
"end_time": event.end_time,
"registration_start_date": event.registration_start_date,
"registration_end_date": event.registration_end_date,
"effective_registration_end_date": event.effective_registration_end_date,
"capacity": event.capacity,
"registration_count": event.current_attendees_count,
"status": event.status,
"status_label": event.status_label,
"is_cancelled": event.is_cancelled,
"image_url": request.build_absolute_uri(event.featured_image.url) if event.featured_image else None,
"participation": registration.status,
})