Update gift cancellation to include received status
All checks were successful
Build and Push Docker Images / changes (push) Successful in 5s
Build and Push Docker Images / build-backend (push) Successful in 49s
Build and Push Docker Images / build-frontend (push) Has been skipped

Allow cancellation of gifts with a status of either RESERVED or RECEIVED. This ensures consistency in handling gift statuses during reservation management across the application.
This commit is contained in:
2025-03-19 07:32:09 +01:00
parent 0410d148d3
commit 7d8eacad7a
2 changed files with 3 additions and 3 deletions

View File

@@ -916,7 +916,7 @@ def cancel_gift_reservation(
raise HTTPException(status_code=404, detail="Gift item not found")
# Check if gift is reserved
if gift.status != GiftStatus.RESERVED:
if gift.status not in [GiftStatus.RESERVED, GiftStatus.RECEIVED]:
raise HTTPException(status_code=400, detail="Gift is not currently reserved")
# Check if guest exists
@@ -931,7 +931,7 @@ def cancel_gift_reservation(
except ValueError as e:
raise HTTPException(status_code=400, detail=str(e))
# Missing the return statement here, which is also a problem
return gift_item_crud.cancel_reservation(db, gift_id=item_id, guest_id=guest_id)
# ===== GIFT PURCHASES ===== #

View File

@@ -136,7 +136,7 @@ class CRUDGiftItem(CRUDBase[GiftItem, GiftItemCreate, GiftItemUpdate]):
raise ValueError(f"Guest with ID {guest_id} not found")
# Only perform the operation if the gift is reserved
if gift.status == GiftStatus.RESERVED:
if gift.status in [GiftStatus.RESERVED, GiftStatus.RECEIVED]:
# Check if this guest has actually reserved this gift
if guest in gift.reserved_by:
gift.reserved_by.remove(guest)