Fix several problems with gift registry api
This commit is contained in:
@@ -926,8 +926,13 @@ def cancel_gift_reservation(
|
||||
|
||||
# For admin users, allow direct cancellation
|
||||
if current_user:
|
||||
return gift_item_crud.cancel_reservation(db, gift_id=item_id, guest_id=guest_id)
|
||||
try:
|
||||
return gift_item_crud.cancel_reservation(db, gift_id=item_id, guest_id=guest_id)
|
||||
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 ===== #
|
||||
|
||||
@@ -1042,6 +1047,4 @@ def read_gift_purchases_by_guest(
|
||||
if not event or not event.is_public:
|
||||
raise HTTPException(status_code=403, detail="Not enough permissions")
|
||||
|
||||
gifts = gift_purchase_crud.get_gift_reservations_by_guest(db, guest_id=guest_id)
|
||||
print(gifts)
|
||||
return gifts
|
||||
return gift_purchase_crud.get_gift_reservations_by_guest(db, guest_id=guest_id)
|
||||
|
||||
@@ -271,11 +271,12 @@ def get_event_by_slug(
|
||||
db: Session = Depends(get_db),
|
||||
slug: str,
|
||||
access_code: Optional[str] = Query(None),
|
||||
current_user: Optional[User] = Depends(get_current_user)
|
||||
current_user: Optional[User] = Depends(get_optional_current_user)
|
||||
) -> EventResponse:
|
||||
"""Get event by slug."""
|
||||
try:
|
||||
event_obj = event_crud.get_by_slug(db=db, slug=slug)
|
||||
print(f"Event {event_obj}")
|
||||
return validate_event_access(
|
||||
db=db,
|
||||
event_obj=event_obj,
|
||||
|
||||
Reference in New Issue
Block a user