# Refactoring eiv-kom remove view
* refactors removing compensation from intervention view * drops unused view on api app
This commit is contained in:
22
intervention/forms/modals/remove.py
Normal file
22
intervention/forms/modals/remove.py
Normal 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)
|
||||
Reference in New Issue
Block a user