mpeltriaux f122778232 # Refactoring team views
* refactors team views
* split views.py into users.py and teams.py in users app
* refactors method headers for _user_has_permission()
* adds method and class comments and documentation to base view classes
2025-11-05 10:12:49 +01:00

43 lines
1.2 KiB
Python

"""
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, **kwargs):
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