""" 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)