mpeltriaux
d0f3fb9f61
* adds support for proper POST of intervention * makes /<id> optional (required for Post)
29 lines
1.2 KiB
Python
29 lines
1.2 KiB
Python
"""
|
|
Author: Michel Peltriaux
|
|
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
|
|
Contact: michel.peltriaux@sgdnord.rlp.de
|
|
Created on: 24.01.22
|
|
|
|
"""
|
|
from api.utils.serializer.v1.serializer import AbstractModelAPISerializerV1
|
|
from ema.models import Ema
|
|
from intervention.models import Responsibility
|
|
|
|
|
|
class EmaAPISerializerV1(AbstractModelAPISerializerV1):
|
|
model = Ema
|
|
|
|
def responsible_to_json(self, responsible: Responsibility):
|
|
return {
|
|
"conservation_office": self.konova_code_to_json(responsible.conservation_office),
|
|
"conservation_file_number": responsible.conservation_file_number,
|
|
"handler": responsible.handler,
|
|
}
|
|
|
|
def extend_properties_data(self, entry):
|
|
self.properties_data["responsible"] = self.responsible_to_json(entry.responsible)
|
|
self.properties_data["before_states"] = self.compensation_state_to_json(entry.before_states.all())
|
|
self.properties_data["after_states"] = self.compensation_state_to_json(entry.after_states.all())
|
|
self.properties_data["actions"] = self.compensation_actions_to_json(entry.actions.all())
|
|
self.properties_data["deadlines"] = self.deadlines_to_json(entry.deadlines.all())
|