master #303
@ -297,9 +297,12 @@ class AbstractCompensationAPISerializerV1Mixin:
|
||||
"""
|
||||
deadlines = []
|
||||
for entry in deadline_data:
|
||||
try:
|
||||
deadline_type = entry["type"]
|
||||
date = entry["date"]
|
||||
comment = entry["comment"]
|
||||
except KeyError:
|
||||
raise ValueError(f"Invalid deadline content. Content was {entry} but should follow the specification")
|
||||
|
||||
# Check on validity
|
||||
if deadline_type not in DeadlineType:
|
||||
@ -341,11 +344,14 @@ class AbstractCompensationAPISerializerV1Mixin:
|
||||
"""
|
||||
states = []
|
||||
for entry in states_data:
|
||||
try:
|
||||
biotope_type = entry["biotope"]
|
||||
biotope_details = [
|
||||
self._konova_code_from_json(e, CODELIST_BIOTOPES_EXTRA_CODES_ID) for e in entry["biotope_details"]
|
||||
]
|
||||
surface = float(entry["surface"])
|
||||
except KeyError:
|
||||
raise ValueError(f"Invalid biotope content. Content was {entry} but should follow the specification ")
|
||||
|
||||
# Check on validity
|
||||
if surface <= 0:
|
||||
@ -385,6 +391,7 @@ class AbstractCompensationAPISerializerV1Mixin:
|
||||
"""
|
||||
actions = []
|
||||
for entry in actions_data:
|
||||
try:
|
||||
action_types = [
|
||||
self._konova_code_from_json(e, CODELIST_COMPENSATION_ACTION_ID) for e in entry["action_types"]
|
||||
]
|
||||
@ -395,6 +402,8 @@ class AbstractCompensationAPISerializerV1Mixin:
|
||||
# Mapping of old "qm" into "m²"
|
||||
unit = UnitChoices.m2.value if entry["unit"] == "qm" else entry["unit"]
|
||||
comment = entry["comment"]
|
||||
except KeyError:
|
||||
raise ValueError(f"Invalid action content. Content was {entry} but should follow specification")
|
||||
|
||||
# Check on validity
|
||||
if amount <= 0:
|
||||
|
Loading…
Reference in New Issue
Block a user