fix(events): prevent resuming unavailable registrations

This commit is contained in:
2026-10-02 13:00:55 +03:30
parent 682ef76396
commit f268c9b88a

View File

@@ -809,7 +809,7 @@ def _my_registration_checkout_fields(registration, now):
checkout_state = "legacy_pending" checkout_state = "legacy_pending"
elif registration.checkout_expires_at > now: elif registration.checkout_expires_at > now:
checkout_state = "active" checkout_state = "active"
can_resume = not bool(payment and payment.verification_manual_review_at) can_resume = _can_resume_registration(registration, payment)
else: else:
checkout_state = "expired" checkout_state = "expired"
elif registration.status == Registration.StatusChoices.CANCELLED: elif registration.status == Registration.StatusChoices.CANCELLED:
@@ -845,6 +845,17 @@ def _my_registration_checkout_fields(registration, now):
} }
def _can_resume_registration(registration, payment):
if payment and payment.verification_manual_review_at:
return False
event = registration.event
return bool(
event.status == Event.StatusChoices.PUBLISHED
and event.is_registration_open
and (event.capacity is None or event.current_attendees_count <= event.capacity)
)
@events_router.get("/my-registrations/paginated", response=PaginatedMyEventRegistrationsSchema, auth=jwt_auth) @events_router.get("/my-registrations/paginated", response=PaginatedMyEventRegistrationsSchema, auth=jwt_auth)
def my_registrations_paginated( def my_registrations_paginated(
request, request,
@@ -962,7 +973,7 @@ def is_registered(request, event_id: int):
checkout_state = "legacy_pending" checkout_state = "legacy_pending"
elif registration.checkout_expires_at > now: elif registration.checkout_expires_at > now:
checkout_state = "active" checkout_state = "active"
can_resume = not bool(payment and payment.verification_manual_review_at) can_resume = _can_resume_registration(registration, payment)
can_cancel = True can_cancel = True
else: else:
checkout_state = "expired" checkout_state = "expired"
@@ -1174,7 +1185,7 @@ def registration_hub_status(
state == "active_checkout" state == "active_checkout"
and registration and registration
and registration.status == Registration.StatusChoices.PENDING and registration.status == Registration.StatusChoices.PENDING
and (payment is None or not payment.verification_manual_review_at) and _can_resume_registration(registration, payment)
) )
can_cancel = bool( can_cancel = bool(
state == "active_checkout" state == "active_checkout"