generated from bisco/codex-bootstrap
feat(admin): add manual reservation operations
This commit is contained in:
@@ -75,6 +75,29 @@ def confirm_check_in_from_token(raw_token, *, staff_user, source=CheckIn.Source.
|
||||
return CheckInResult(check_in=check_in, preview=_build_preview(reservation))
|
||||
|
||||
|
||||
def confirm_check_in_for_reservation(*, reservation_id, staff_user, source=CheckIn.Source.MANUAL):
|
||||
_validate_staff_user(staff_user)
|
||||
|
||||
with transaction.atomic():
|
||||
reservation = (
|
||||
Reservation.objects.select_for_update()
|
||||
.select_related("performance__show", "performance__venue")
|
||||
.get(pk=reservation_id)
|
||||
)
|
||||
_validate_reservation_for_check_in(reservation)
|
||||
|
||||
try:
|
||||
check_in = CheckIn.objects.create(
|
||||
reservation=reservation,
|
||||
checked_in_by=staff_user,
|
||||
source=source,
|
||||
)
|
||||
except IntegrityError as exc:
|
||||
raise AlreadyCheckedIn("Reservation has already been checked in.") from exc
|
||||
|
||||
return CheckInResult(check_in=check_in, preview=_build_preview(reservation))
|
||||
|
||||
|
||||
def _validate_staff_user(staff_user):
|
||||
if staff_user is None:
|
||||
raise MissingStaffUser("A staff user is required for check-in.")
|
||||
|
||||
Reference in New Issue
Block a user