118_API_update #119
@ -367,7 +367,9 @@ class AbstractCompensationAPISerializerV1Mixin:
|
|||||||
"""
|
"""
|
||||||
actions = []
|
actions = []
|
||||||
for entry in actions_data:
|
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 = [
|
action_details = [
|
||||||
self._konova_code_from_json(e, CODELIST_COMPENSATION_ACTION_DETAIL_ID) for e in entry["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
|
# 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
|
# entries, we will use to set the new actions
|
||||||
action_entry = obj.actions.filter(
|
action_entry = obj.actions.filter(
|
||||||
action_type__atom_id=action,
|
action_type__in=action_types,
|
||||||
amount=amount,
|
amount=amount,
|
||||||
unit=unit,
|
unit=unit,
|
||||||
comment=comment,
|
comment=comment,
|
||||||
@ -396,13 +398,13 @@ class AbstractCompensationAPISerializerV1Mixin:
|
|||||||
else:
|
else:
|
||||||
# Create and add id to list
|
# Create and add id to list
|
||||||
action_entry = CompensationAction.objects.create(
|
action_entry = CompensationAction.objects.create(
|
||||||
action_type=self._konova_code_from_json(action, CODELIST_COMPENSATION_ACTION_ID),
|
|
||||||
amount=amount,
|
amount=amount,
|
||||||
unit=unit,
|
unit=unit,
|
||||||
comment=comment,
|
comment=comment,
|
||||||
)
|
)
|
||||||
actions.append(action_entry.id)
|
actions.append(action_entry.id)
|
||||||
|
|
||||||
|
action_entry.action_type.set(action_types)
|
||||||
action_entry.action_type_details.set(action_details)
|
action_entry.action_type_details.set(action_details)
|
||||||
obj.actions.set(actions)
|
obj.actions.set(actions)
|
||||||
return obj
|
return obj
|
||||||
@ -438,7 +440,9 @@ class AbstractCompensationAPISerializerV1Mixin:
|
|||||||
"""
|
"""
|
||||||
return [
|
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": [
|
"action_details": [
|
||||||
self._konova_code_to_json(detail) for detail in entry.action_type_details.all()
|
self._konova_code_to_json(detail) for detail in entry.action_type_details.all()
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user