2022-01-21 15:26:08 +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 16:29:59 +01:00
|
|
|
from django.db.models import QuerySet
|
2022-01-21 15:26:08 +01:00
|
|
|
|
2022-01-21 18:34:01 +01:00
|
|
|
from api.views.v1.views import AbstractModelAPIViewV1
|
2022-01-21 15:26:08 +01:00
|
|
|
from intervention.models import Intervention
|
|
|
|
|
|
|
|
|
2022-01-21 16:15:16 +01:00
|
|
|
class APIInterventionViewV1(AbstractModelAPIViewV1):
|
2022-01-21 15:26:08 +01:00
|
|
|
model = Intervention
|
|
|
|
|
2022-01-21 16:29:59 +01:00
|
|
|
def compensations_to_json(self, qs: QuerySet):
|
|
|
|
return list(
|
|
|
|
qs.values(
|
|
|
|
"id", "identifier", "title"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
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["legal"] = self.legal_to_json(entry.legal)
|
|
|
|
self.properties_data["compensations"] = self.compensations_to_json(entry.compensations.all())
|
|
|
|
self.properties_data["payments"] = self.payments_to_json(entry.payments.all())
|
|
|
|
self.properties_data["deductions"] = self.deductions_to_json(entry.deductions.all())
|