This commit is contained in:
@@ -32,7 +32,7 @@ async def get_forms_filtered(
|
||||
async def get_form(id: int, session: Session = Depends(get_session)):
|
||||
result = service.get_one(session, id)
|
||||
if result is None:
|
||||
raise HTTPException(status_code=404, detail=messages.notfound)
|
||||
raise HTTPException(status_code=404, detail=messages.Messages.not_found('form'))
|
||||
return result
|
||||
|
||||
@router.post('', response_model=models.FormPublic)
|
||||
@@ -43,12 +43,12 @@ async def create_form(
|
||||
):
|
||||
try:
|
||||
form = service.create_one(session, form)
|
||||
except exceptions.ProductorNotFoundError:
|
||||
raise HTTPException(status_code=404, detail=messages.productornotfound)
|
||||
except exceptions.UserNotFoundError:
|
||||
raise HTTPException(status_code=404, detail=messages.usernotfound)
|
||||
except exceptions.FormCreateError:
|
||||
raise HTTPException(status_code=400, detail=messages.forminputinvalid)
|
||||
except exceptions.ProductorNotFoundError as error:
|
||||
raise HTTPException(status_code=404, detail=str(error))
|
||||
except exceptions.UserNotFoundError as error:
|
||||
raise HTTPException(status_code=404, detail=str(error))
|
||||
except exceptions.FormCreateError as error:
|
||||
raise HTTPException(status_code=400, detail=str(error))
|
||||
return form
|
||||
|
||||
@router.put('/{id}', response_model=models.FormPublic)
|
||||
@@ -59,12 +59,12 @@ async def update_form(
|
||||
):
|
||||
try:
|
||||
result = service.update_one(session, id, form)
|
||||
except exceptions.FormNotFoundError:
|
||||
raise HTTPException(status_code=404, detail=messages.notfound)
|
||||
except exceptions.ProductorNotFoundError:
|
||||
raise HTTPException(status_code=404, detail=messages.productornotfound)
|
||||
except exceptions.UserNotFoundError:
|
||||
raise HTTPException(status_code=404, detail=messages.usernotfound)
|
||||
except exceptions.FormNotFoundError as error:
|
||||
raise HTTPException(status_code=404, detail=str(error))
|
||||
except exceptions.ProductorNotFoundError as error:
|
||||
raise HTTPException(status_code=404, detail=str(error))
|
||||
except exceptions.UserNotFoundError as error:
|
||||
raise HTTPException(status_code=404, detail=str(error))
|
||||
return result
|
||||
|
||||
@router.delete('/{id}', response_model=models.FormPublic)
|
||||
@@ -75,6 +75,6 @@ async def delete_form(
|
||||
):
|
||||
try:
|
||||
result = service.delete_one(session, id)
|
||||
except exceptions.FormNotFoundError:
|
||||
raise HTTPException(status_code=404, detail=messages.notfound)
|
||||
except exceptions.FormNotFoundError as error:
|
||||
raise HTTPException(status_code=404, detail=str(error))
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user