shifting the ship-id check into the validation object
This commit is contained in:
parent
82ad56812e
commit
aaea8441f6
@ -100,10 +100,7 @@ def DeleteShip():
|
|||||||
|
|
||||||
# validate the request data & user permissions
|
# validate the request data & user permissions
|
||||||
ship_id = request.args.get("id")
|
ship_id = request.args.get("id")
|
||||||
if ship_id is None:
|
InputValidationShip.evaluate_delete_data(user_data, ship_id)
|
||||||
return create_dynamic_exception_response(ex=None, status_code=400, message="no id provided")
|
|
||||||
|
|
||||||
InputValidationShip.evaluate_delete_data(user_data, int(ship_id))
|
|
||||||
return impl.ships.DeleteShip(options)
|
return impl.ships.DeleteShip(options)
|
||||||
|
|
||||||
except ValidationError as ex:
|
except ValidationError as ex:
|
||||||
|
|||||||
@ -60,7 +60,11 @@ class InputValidationShip():
|
|||||||
return
|
return
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def evaluate_delete_data(user_data:dict, ship_id:int):
|
def evaluate_delete_data(user_data:dict, ship_id:typing.Optional[int]):
|
||||||
|
if ship_id is None:
|
||||||
|
raise ValidationError({"id":f"The ship id must be provided."})
|
||||||
|
ship_id = int(ship_id)
|
||||||
|
|
||||||
# 1.) Only users of type BSMD are allowed to PUT
|
# 1.) Only users of type BSMD are allowed to PUT
|
||||||
InputValidationShip.check_user_is_bsmd_type(user_data)
|
InputValidationShip.check_user_is_bsmd_type(user_data)
|
||||||
|
|
||||||
@ -129,9 +133,6 @@ class InputValidationShip():
|
|||||||
makes sure, that the request contains and ID, has a matching entry in the database, and the
|
makes sure, that the request contains and ID, has a matching entry in the database, and the
|
||||||
database entry may not have a deletion state already.
|
database entry may not have a deletion state already.
|
||||||
"""
|
"""
|
||||||
if ship_id is None:
|
|
||||||
raise ValidationError({"id":f"The ship id must be provided."})
|
|
||||||
|
|
||||||
response, status_code, header = GetShips(token=None)
|
response, status_code, header = GetShips(token=None)
|
||||||
ships = json.loads(response)
|
ships = json.loads(response)
|
||||||
existing_database_entries = [ship for ship in ships if ship.get("id")==int(ship_id)]
|
existing_database_entries = [ship for ship in ships if ship.get("id")==int(ship_id)]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user