""" Author: Michel Peltriaux Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany Contact: michel.peltriaux@sgdnord.rlp.de Created on: 09.08.21 """ from django.contrib.auth.mixins import LoginRequiredMixin from compensation.forms.modals.payment import NewPaymentForm, RemovePaymentModalForm, EditPaymentModalForm from intervention.models import Intervention from konova.utils.message_templates import PAYMENT_ADDED, PAYMENT_REMOVED, PAYMENT_EDITED from konova.views.base import BaseModalFormView class BasePaymentView(LoginRequiredMixin, BaseModalFormView): _MODEL_CLS = Intervention _REDIRECT_URL = "intervention:detail" class Meta: abstract = True def _get_redirect_url(self, *args, **kwargs): url = super()._get_redirect_url(*args, **kwargs) return f"{url}#related_data" def _user_has_permission(self, user): return user.is_default_user() class NewPaymentView(BasePaymentView): _FORM_CLS = NewPaymentForm _MSG_SUCCESS = PAYMENT_ADDED class EditPaymentView(BasePaymentView): _MSG_SUCCESS = PAYMENT_EDITED _FORM_CLS = EditPaymentModalForm class RemovePaymentView(BasePaymentView): _MSG_SUCCESS = PAYMENT_REMOVED _FORM_CLS = RemovePaymentModalForm