From e1d9570268081c53d60c72726e5309171bf268c9 Mon Sep 17 00:00:00 2001 From: Max Metz Date: Tue, 27 Aug 2024 20:52:10 +0200 Subject: [PATCH] solving the concatenation issue of a list and a None-type. --- src/server/BreCal/database/enums.py | 4 ++++ .../BreCal/validators/input_validation_times.py | 15 ++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/server/BreCal/database/enums.py b/src/server/BreCal/database/enums.py index 04516fc..a3c7de1 100644 --- a/src/server/BreCal/database/enums.py +++ b/src/server/BreCal/database/enums.py @@ -62,3 +62,7 @@ class ParticipantFlag(IntFlag): """ undefined = 0 BSMD = 1 + + @classmethod + def _missing_(cls, value): + return cls.undefined diff --git a/src/server/BreCal/validators/input_validation_times.py b/src/server/BreCal/validators/input_validation_times.py index e2c01ef..0385220 100644 --- a/src/server/BreCal/validators/input_validation_times.py +++ b/src/server/BreCal/validators/input_validation_times.py @@ -27,8 +27,8 @@ def build_post_data_type_dependent_required_fields_dict()->dict[ShipcallType,dic """ post_data_type_dependent_required_fields_dict = { ShipcallType.arrival:{ - ParticipantType.undefined:None, # should not be set in POST requests - ParticipantType.BSMD:None, # 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.TERMINAL:["operations_start"], ParticipantType.AGENCY:["eta_berth"], ParticipantType.MOORING:["eta_berth"], @@ -37,8 +37,8 @@ def build_post_data_type_dependent_required_fields_dict()->dict[ShipcallType,dic ParticipantType.TUG:["eta_berth"], }, ShipcallType.departure:{ - ParticipantType.undefined:None, # should not be set in POST requests - ParticipantType.BSMD:None, # 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.TERMINAL:["operations_end"], ParticipantType.AGENCY:["etd_berth"], ParticipantType.MOORING:["etd_berth"], @@ -47,8 +47,8 @@ def build_post_data_type_dependent_required_fields_dict()->dict[ShipcallType,dic ParticipantType.TUG:["etd_berth"], }, ShipcallType.shifting:{ - ParticipantType.undefined:None, # should not be set in POST requests - ParticipantType.BSMD:None, # 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.TERMINAL:["operations_start", "operations_end"], ParticipantType.AGENCY:["eta_berth", "etd_berth"], ParticipantType.MOORING:["eta_berth", "etd_berth"], @@ -270,7 +270,8 @@ class InputValidationTimes(): dependent_required_fields_dict = build_post_data_type_dependent_required_fields_dict() # select shipcall type & participant type - dependent_required_fields = dependent_required_fields_dict.get(shipcall_type,{}).get(participant_type,None) + dependent_required_fields = dependent_required_fields_dict.get(shipcall_type,{}).get(participant_type,[]) + dependent_required_fields = dependent_required_fields if dependent_required_fields is not None else [] return dependent_required_fields @staticmethod