2022-01-21 17:49:07 +01:00
|
|
|
"""
|
|
|
|
Author: Michel Peltriaux
|
|
|
|
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
|
|
|
|
Contact: michel.peltriaux@sgdnord.rlp.de
|
|
|
|
Created on: 21.01.22
|
|
|
|
|
|
|
|
"""
|
2022-01-21 18:34:01 +01:00
|
|
|
from api.views.v1.views import AbstractModelAPIViewV1
|
2022-01-21 17:49:07 +01:00
|
|
|
from ema.models import Ema
|
2022-01-21 18:34:01 +01:00
|
|
|
from intervention.models import Responsibility
|
2022-01-21 17:49:07 +01:00
|
|
|
|
|
|
|
|
2022-01-21 18:34:01 +01:00
|
|
|
class APIEmaViewV1(AbstractModelAPIViewV1):
|
2022-01-21 17:49:07 +01:00
|
|
|
model = Ema
|
|
|
|
|
2022-01-21 18:34:01 +01:00
|
|
|
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,
|
2022-01-21 17:49:07 +01:00
|
|
|
}
|
2022-01-21 18:34:01 +01:00
|
|
|
|
|
|
|
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())
|