|
|
|
@ -367,7 +367,9 @@ class AbstractCompensationAPISerializerV1Mixin:
|
|
|
|
|
"""
|
|
|
|
|
actions = []
|
|
|
|
|
for entry in actions_data:
|
|
|
|
|
action = entry["action"]
|
|
|
|
|
action_types = [
|
|
|
|
|
self._konova_code_from_json(e, CODELIST_COMPENSATION_ACTION_ID) for e in entry["action_types"]
|
|
|
|
|
]
|
|
|
|
|
action_details = [
|
|
|
|
|
self._konova_code_from_json(e, CODELIST_COMPENSATION_ACTION_DETAIL_ID) for e in entry["action_details"]
|
|
|
|
|
]
|
|
|
|
@ -384,7 +386,7 @@ class AbstractCompensationAPISerializerV1Mixin:
|
|
|
|
|
# If this exact data is already existing, we do not create it new. Instead put it's id in the list of
|
|
|
|
|
# entries, we will use to set the new actions
|
|
|
|
|
action_entry = obj.actions.filter(
|
|
|
|
|
action_type__atom_id=action,
|
|
|
|
|
action_type__in=action_types,
|
|
|
|
|
amount=amount,
|
|
|
|
|
unit=unit,
|
|
|
|
|
comment=comment,
|
|
|
|
@ -396,13 +398,13 @@ class AbstractCompensationAPISerializerV1Mixin:
|
|
|
|
|
else:
|
|
|
|
|
# Create and add id to list
|
|
|
|
|
action_entry = CompensationAction.objects.create(
|
|
|
|
|
action_type=self._konova_code_from_json(action, CODELIST_COMPENSATION_ACTION_ID),
|
|
|
|
|
amount=amount,
|
|
|
|
|
unit=unit,
|
|
|
|
|
comment=comment,
|
|
|
|
|
)
|
|
|
|
|
actions.append(action_entry.id)
|
|
|
|
|
|
|
|
|
|
action_entry.action_type.set(action_types)
|
|
|
|
|
action_entry.action_type_details.set(action_details)
|
|
|
|
|
obj.actions.set(actions)
|
|
|
|
|
return obj
|
|
|
|
@ -438,7 +440,9 @@ class AbstractCompensationAPISerializerV1Mixin:
|
|
|
|
|
"""
|
|
|
|
|
return [
|
|
|
|
|
{
|
|
|
|
|
"action": self._konova_code_to_json(entry.action_type),
|
|
|
|
|
"action_types": [
|
|
|
|
|
self._konova_code_to_json(action) for action in entry.action_type.all()
|
|
|
|
|
],
|
|
|
|
|
"action_details": [
|
|
|
|
|
self._konova_code_to_json(detail) for detail in entry.action_type_details.all()
|
|
|
|
|
],
|
|
|
|
|