#31 API POST Intervention
* adds support for proper POST of intervention * makes /<id> optional (required for Post)
This commit is contained in:
37
api/utils/serializer/v1/ecoaccount.py
Normal file
37
api/utils/serializer/v1/ecoaccount.py
Normal file
@@ -0,0 +1,37 @@
|
||||
"""
|
||||
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 compensation.models import EcoAccount
|
||||
from intervention.models import Legal, Responsibility
|
||||
|
||||
|
||||
class EcoAccountAPISerializerV1(AbstractModelAPISerializerV1):
|
||||
model = EcoAccount
|
||||
|
||||
def extend_properties_data(self, entry):
|
||||
self.properties_data["deductable_surface"] = entry.deductable_surface
|
||||
self.properties_data["deductable_surface_available"] = entry.deductable_surface - entry.get_deductions_surface()
|
||||
self.properties_data["responsible"] = self.responsible_to_json(entry.responsible)
|
||||
self.properties_data["legal"] = self.legal_to_json(entry.legal)
|
||||
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())
|
||||
self.properties_data["deductions"] = self.deductions_to_json(entry.deductions.all())
|
||||
|
||||
def legal_to_json(self, legal: Legal):
|
||||
return {
|
||||
"agreement_date": legal.registration_date,
|
||||
}
|
||||
|
||||
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,
|
||||
}
|
||||
Reference in New Issue
Block a user