fix(events): keep registration status reads nonblocking

This commit is contained in:
2026-10-01 13:35:17 +03:30
parent 962238c32c
commit f924fcc52e
16 changed files with 498 additions and 107 deletions

View File

@@ -39,7 +39,7 @@ from apps.events.models import Event, Registration
from apps.events.checkout import (
CHECKOUT_TIMEOUT,
cancel_event_checkouts,
expire_stale_registration_checkouts,
expire_user_registration_checkouts,
mark_checkout_cancelled,
queue_checkout_reconciliation,
)
@@ -599,8 +599,13 @@ def register_for_event(
"""Register current user for an event"""
user = request.auth
now = timezone.now()
expire_stale_registration_checkouts(now=now, event_id=event_id)
with transaction.atomic():
event = get_object_or_404(
Event.objects.select_for_update(),
id=event_id,
is_deleted=False,
)
expire_user_registration_checkouts(event=event, user=user, now=now)
with transaction.atomic():
event = get_object_or_404(
Event.objects.select_for_update(),
@@ -937,10 +942,6 @@ def is_registered(request, event_id: int):
.order_by("-registered_at", "-id")
.first()
)
if registration and registration.status == Registration.StatusChoices.PENDING and registration.checkout_expires_at and registration.checkout_expires_at <= now:
expire_stale_registration_checkouts(now=now, event_id=event_id)
registration.refresh_from_db()
payment = None
if registration:
payment = registration.payments.order_by("-created_at", "-id").first()
@@ -1154,7 +1155,6 @@ def registration_hub_status(
lookup = {"pk": int(slug)} if slug.isdecimal() else {"slug": slug}
event = get_object_or_404(Event, is_deleted=False, **lookup)
now = timezone.now()
expire_stale_registration_checkouts(now=now, event_id=event.id)
registration, payment = _registration_hub_records(
event,
request.auth,