adding missing defaults when shipcall is not yet created

This commit is contained in:
Daniel Schick 2024-11-12 08:19:04 +01:00
parent 9bb847242c
commit 3775d6775c

View File

@ -264,11 +264,11 @@ class InputValidationShipcall():
raise ValidationError({"participants":f"every participant id and type should be listed only once. Found multiple entries for one of the participants."}) raise ValidationError({"participants":f"every participant id and type should be listed only once. Found multiple entries for one of the participants."})
@staticmethod @staticmethod
def check_shipcall_type_is_unchanged(loadedModel:dict, existing_shipcall:object): def check_shipcall_type_is_unchanged(loadedModel:dict, existing_shipcall:object):
if int(loadedModel["type"]) != int(existing_shipcall.type): if int(loadedModel["type"]) != int(existing_shipcall.type):
raise ValidationError({"type":f"The shipcall type may only be set in the initial POST-request. Afterwards, changing the shipcall type is not allowed."}) # @pytest.raises raise ValidationError({"type":f"The shipcall type may only be set in the initial POST-request. Afterwards, changing the shipcall type is not allowed."}) # @pytest.raises
return return
@staticmethod @staticmethod
def get_shipcall_by_id(shipcall_id:int): def get_shipcall_by_id(shipcall_id:int):
query = SQLQuery.get_shipcall_by_id() query = SQLQuery.get_shipcall_by_id()
@ -357,6 +357,10 @@ class InputValidationShipcall():
etd = loadedModel.get("etd") etd = loadedModel.get("etd")
tidal_window_from = loadedModel.get("tidal_window_from", None) tidal_window_from = loadedModel.get("tidal_window_from", None)
tidal_window_to = loadedModel.get("tidal_window_to", None) tidal_window_to = loadedModel.get("tidal_window_to", None)
existing_eta = None
existing_etd = None
existing_tidal_window_from = None
existing_tidal_window_to = None
if existing_shipcall is not None: if existing_shipcall is not None:
existing_eta = existing_shipcall.eta existing_eta = existing_shipcall.eta