#31 API Deductions
* adds GET/POST/PUT/DELETE support for EcoAccountDeductions
This commit is contained in:
@@ -132,6 +132,30 @@ class DeductableAPISerializerV1Mixin:
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
def _single_deduction_to_json(self, entry):
|
||||
""" Serializes a single eco account deduction into json
|
||||
|
||||
Args:
|
||||
entry (EcoAccountDeduction): An EcoAccountDeduction
|
||||
|
||||
Returns:
|
||||
serialized_json (dict)
|
||||
"""
|
||||
return {
|
||||
"id": entry.pk,
|
||||
"eco_account": {
|
||||
"id": entry.account.pk,
|
||||
"identifier": entry.account.identifier,
|
||||
"title": entry.account.title,
|
||||
},
|
||||
"surface": entry.surface,
|
||||
"intervention": {
|
||||
"id": entry.intervention.pk,
|
||||
"identifier": entry.intervention.identifier,
|
||||
"title": entry.intervention.title,
|
||||
}
|
||||
}
|
||||
|
||||
def _deductions_to_json(self, qs: QuerySet):
|
||||
""" Serializes eco account deductions into json
|
||||
|
||||
@@ -142,20 +166,7 @@ class DeductableAPISerializerV1Mixin:
|
||||
serialized_json (list)
|
||||
"""
|
||||
return [
|
||||
{
|
||||
"id": entry.pk,
|
||||
"eco_account": {
|
||||
"id": entry.account.pk,
|
||||
"identifier": entry.account.identifier,
|
||||
"title": entry.account.title,
|
||||
},
|
||||
"surface": entry.surface,
|
||||
"intervention": {
|
||||
"id": entry.intervention.pk,
|
||||
"identifier": entry.intervention.identifier,
|
||||
"title": entry.intervention.title,
|
||||
}
|
||||
}
|
||||
self._single_deduction_to_json(entry)
|
||||
for entry in qs
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user