Merge pull request #50 from puls200/hotfix/20240912

Hotfix/20240912
This commit is contained in:
Daniel Schick 2024-09-18 08:27:36 +02:00 committed by GitHub
commit df050cb83b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View File

@ -97,7 +97,7 @@ class InputValidationShip():
ships = json.loads(response) ships = json.loads(response)
# extract only the 'imo' values # extract only the 'imo' values
ship_imos = [ship.get("imo") for ship in ships] ship_imos = [ship.get("imo") for ship in ships if not ship.deleted]
# check, if the imo in the POST-request already exists in the list # check, if the imo in the POST-request already exists in the list
imo_already_exists = loadedModel.get("imo") in ship_imos imo_already_exists = loadedModel.get("imo") in ship_imos

View File

@ -465,6 +465,9 @@ class InputValidationShipcall():
def check_shipcall_id_exists(loadedModel): def check_shipcall_id_exists(loadedModel):
"""simply checks, whether the defined shipcall ID exists in the database. Otherwise, a PUT-request must fail.""" """simply checks, whether the defined shipcall ID exists in the database. Otherwise, a PUT-request must fail."""
shipcall_id = loadedModel.get("id") shipcall_id = loadedModel.get("id")
if shipcall_id is None:
raise ValidationError({"id":"a shipcall id must be provided"})
query = 'SELECT * FROM shipcall where (id = ?shipcall_id?)' query = 'SELECT * FROM shipcall where (id = ?shipcall_id?)'
shipcalls = execute_sql_query_standalone(query=query, model=Shipcall, param={"shipcall_id" : shipcall_id}) shipcalls = execute_sql_query_standalone(query=query, model=Shipcall, param={"shipcall_id" : shipcall_id})
if len(shipcalls)==0: if len(shipcalls)==0:
@ -509,7 +512,7 @@ class InputValidationShipcall():
# determine, whether the assigned agency has set the BSMD-flag to allow BSMD users to edit their assigned shipcalls # determine, whether the assigned agency has set the BSMD-flag to allow BSMD users to edit their assigned shipcalls
query = 'SELECT * FROM participant where (id = ?participant_id?)' query = 'SELECT * FROM participant where (id = ?participant_id?)'
agency_participant = execute_sql_query_standalone(query=query, param={"participant_id" : participant_id}, command_type="single", model=Participant) agency_participant = execute_sql_query_standalone(query=query, param={"participant_id" : assigned_agency.participant_id}, command_type="single", model=Participant)
assert isinstance(agency_participant.flags, int), f"this method has currently only been developed with 'flags' being set as an integer. Found: {type(agency_participant.flags)}" assert isinstance(agency_participant.flags, int), f"this method has currently only been developed with 'flags' being set as an integer. Found: {type(agency_participant.flags)}"
agency_has_bsmd_flag = agency_participant.flags==1 # once the flags are an IntFlag, change the boolean check to: (ParticipantFlag.BSMD in agency_participant.flags) agency_has_bsmd_flag = agency_participant.flags==1 # once the flags are an IntFlag, change the boolean check to: (ParticipantFlag.BSMD in agency_participant.flags)