time estimations are no longer dependency on times POST requests. This refers to eta_berth, etd_berth, operations_start, operations_end.

This commit is contained in:
Max Metz 2024-09-04 11:41:03 +02:00
parent a8d0356eb7
commit 2f678267c8

View File

@ -29,32 +29,32 @@ def build_post_data_type_dependent_required_fields_dict()->dict[ShipcallType,dic
ShipcallType.arrival:{ ShipcallType.arrival:{
ParticipantType.undefined:[], # should not be set in POST requests ParticipantType.undefined:[], # should not be set in POST requests
ParticipantType.BSMD:[], # should not be set in POST requests ParticipantType.BSMD:[], # should not be set in POST requests
ParticipantType.TERMINAL:["operations_start"], ParticipantType.TERMINAL:[],
ParticipantType.AGENCY:["eta_berth"], ParticipantType.AGENCY:[],
ParticipantType.MOORING:["eta_berth"], ParticipantType.MOORING:[],
ParticipantType.PILOT:["eta_berth"], ParticipantType.PILOT:[],
ParticipantType.PORT_ADMINISTRATION:["eta_berth"], ParticipantType.PORT_ADMINISTRATION:[],
ParticipantType.TUG:["eta_berth"], ParticipantType.TUG:[],
}, },
ShipcallType.departure:{ ShipcallType.departure:{
ParticipantType.undefined:[], # should not be set in POST requests ParticipantType.undefined:[], # should not be set in POST requests
ParticipantType.BSMD:[], # should not be set in POST requests ParticipantType.BSMD:[], # should not be set in POST requests
ParticipantType.TERMINAL:["operations_end"], ParticipantType.TERMINAL:[],
ParticipantType.AGENCY:["etd_berth"], ParticipantType.AGENCY:[],
ParticipantType.MOORING:["etd_berth"], ParticipantType.MOORING:[],
ParticipantType.PILOT:["etd_berth"], ParticipantType.PILOT:[],
ParticipantType.PORT_ADMINISTRATION:["etd_berth"], ParticipantType.PORT_ADMINISTRATION:[],
ParticipantType.TUG:["etd_berth"], ParticipantType.TUG:[],
}, },
ShipcallType.shifting:{ ShipcallType.shifting:{
ParticipantType.undefined:[], # should not be set in POST requests ParticipantType.undefined:[], # should not be set in POST requests
ParticipantType.BSMD:[], # should not be set in POST requests ParticipantType.BSMD:[], # should not be set in POST requests
ParticipantType.TERMINAL:["operations_start"], ParticipantType.TERMINAL:[],
ParticipantType.AGENCY:["etd_berth"], ParticipantType.AGENCY:[],
ParticipantType.MOORING:["etd_berth"], ParticipantType.MOORING:[],
ParticipantType.PILOT:["etd_berth"], ParticipantType.PILOT:[],
ParticipantType.PORT_ADMINISTRATION:["etd_berth"], ParticipantType.PORT_ADMINISTRATION:[],
ParticipantType.TUG:["etd_berth"], ParticipantType.TUG:[],
}, },
} }
return post_data_type_dependent_required_fields_dict return post_data_type_dependent_required_fields_dict
@ -482,3 +482,44 @@ class InputValidationTimes():
has_bsmd_flag = ParticipantFlag.BSMD in [ParticipantFlag(participant.get("flags"))] has_bsmd_flag = ParticipantFlag.BSMD in [ParticipantFlag(participant.get("flags"))]
return has_bsmd_flag return has_bsmd_flag
def deprecated_build_post_data_type_dependent_required_fields_dict()->dict[ShipcallType,dict[ParticipantType,typing.Optional[list[str]]]]:
"""
The required fields of a POST-request depend on ShipcallType and ParticipantType. This function creates
a dictionary, which maps those types to a list of required fields.
The participant types 'undefined' and 'bsmd' should not be used in POST-requests. They return 'None'.
"""
post_data_type_dependent_required_fields_dict = {
ShipcallType.arrival:{
ParticipantType.undefined:[], # should not be set in POST requests
ParticipantType.BSMD:[], # should not be set in POST requests
ParticipantType.TERMINAL:[],
ParticipantType.AGENCY:["eta_berth"],
ParticipantType.MOORING:["eta_berth"],
ParticipantType.PILOT:["eta_berth"],
ParticipantType.PORT_ADMINISTRATION:["eta_berth"],
ParticipantType.TUG:["eta_berth"],
},
ShipcallType.departure:{
ParticipantType.undefined:[], # should not be set in POST requests
ParticipantType.BSMD:[], # should not be set in POST requests
ParticipantType.TERMINAL:[],
ParticipantType.AGENCY:["etd_berth"],
ParticipantType.MOORING:["etd_berth"],
ParticipantType.PILOT:["etd_berth"],
ParticipantType.PORT_ADMINISTRATION:["etd_berth"],
ParticipantType.TUG:["etd_berth"],
},
ShipcallType.shifting:{
ParticipantType.undefined:[], # should not be set in POST requests
ParticipantType.BSMD:[], # should not be set in POST requests
ParticipantType.TERMINAL:[],
ParticipantType.AGENCY:["etd_berth"],
ParticipantType.MOORING:["etd_berth"],
ParticipantType.PILOT:["etd_berth"],
ParticipantType.PORT_ADMINISTRATION:["etd_berth"],
ParticipantType.TUG:["etd_berth"],
},
}
return post_data_type_dependent_required_fields_dict