fixed POST when a null evaluation enum is sent

This commit is contained in:
Daniel Schick 2024-04-08 13:49:52 +02:00
parent 40fd77bf6c
commit 08dd104284

View File

@ -62,7 +62,7 @@ class ShipcallType(IntEnum):
arrival = 1 arrival = 1
departure = 2 departure = 2
shifting = 3 shifting = 3
@classmethod @classmethod
def _missing_(cls, value): def _missing_(cls, value):
return cls.undefined return cls.undefined
@ -194,9 +194,13 @@ class ShipcallSchema(Schema):
@post_load @post_load
def make_shipcall(self, data, **kwargs): def make_shipcall(self, data, **kwargs):
data['type_value'] = data['type'].value if 'type' in data:
data['type_value'] = data['type'].value
else:
data['type_value'] = ShipcallType.undefined
if 'evaluation' in data: if 'evaluation' in data:
data['evaluation_value'] = data['evaluation'].value if data['evaluation']:
data['evaluation_value'] = data['evaluation'].value
else: else:
data['evaluation_value'] = EvaluationType.undefined data['evaluation_value'] = EvaluationType.undefined
return data return data