Skip to content

Commit

Permalink
fix ticket scan endpoints url
Browse files Browse the repository at this point in the history
  • Loading branch information
Malem38 committed Aug 11, 2024
1 parent 9c347d0 commit 6fba1a3
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions app/modules/cdr/endpoints_cdr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2142,11 +2142,12 @@ async def get_ticket_secret(


@module.router.get(
"/cdr/tickets/{secret}/",
"/cdr/products/{product_id}/tickets/{secret}/",
response_model=list[schemas_cdr.Ticket],
status_code=200,
)
async def get_ticket_by_secret(
product_id: UUID,
secret: UUID,
db: AsyncSession = Depends(get_db),
user: models_core.CoreUser = Depends(is_user_a_member),
Expand All @@ -2157,9 +2158,14 @@ async def get_ticket_by_secret(
status_code=404,
detail="Ticket not found.",
)
if ticket.product_variant.product_id != product_id:
raise HTTPException(
status_code=404,
detail="This Ticket is not related to this product.",
)
product = await cruds_cdr.get_product_by_id(
db=db,
product_id=ticket.product_variant.product_id,
product_id=product_id,
)
if not product:
raise HTTPException(
Expand All @@ -2183,10 +2189,11 @@ async def get_ticket_by_secret(


@module.router.patch(
"/cdr/tickets/{secret}/",
"/cdr/products/{product_id}/tickets/{secret}/",
status_code=204,
)
async def scan_ticket(
product_id: UUID,
secret: UUID,
ticket_data: schemas_cdr.TicketScan,
db: AsyncSession = Depends(get_db),
Expand All @@ -2198,9 +2205,14 @@ async def scan_ticket(
status_code=404,
detail="Ticket not found.",
)
if ticket.product_variant.product_id != product_id:
raise HTTPException(
status_code=404,
detail="This Ticket is not related to this product.",
)
product = await cruds_cdr.get_product_by_id(
db=db,
product_id=ticket.product_variant.product_id,
product_id=product_id,
)
if not product:
raise HTTPException(
Expand Down

0 comments on commit 6fba1a3

Please sign in to comment.