# Refactoring eiv-kom remove view

* refactors removing compensation from intervention view
* drops unused view on api app
This commit is contained in:
2025-11-08 13:05:14 +01:00
parent 1ac73e4bbb
commit a70434e2cc
7 changed files with 251 additions and 281 deletions

View File

@@ -0,0 +1,22 @@
"""
Author: Michel Peltriaux
Created on: 08.11.25
"""
from django.shortcuts import get_object_or_404
from compensation.models import Compensation
from konova.forms.modals import RemoveModalForm
class RemoveCompensationFromInterventionModalForm(RemoveModalForm):
""" Specific form for removing a compensation from an intervention
"""
def __init__(self, *args, **kwargs):
# The 'instance' that is pushed into the constructor by the generic base class points to the
# intervention instead of the compensation, which shall be deleted. Therefore we need to fetch the compensation
# and replace the instance parameter with that object
instance = get_object_or_404(Compensation, id=kwargs.pop("comp_id"))
kwargs["instance"] = instance
super().__init__(*args, **kwargs)