* extends BaseModalFormView to hold general logic for processing GET and POST requests for BaseModalForm endpoints * refactors uuid check to use a specific parameter instead of kwargs * fixes css bug where modal form input elements would not be visible * refactors check view for intervention from function to class * refactors DeductionViews to inherit from extended BaseModalFormView
34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
"""
|
|
Author: Michel Peltriaux
|
|
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
|
|
Contact: ksp-servicestelle@sgdnord.rlp.de
|
|
Created on: 19.08.22
|
|
|
|
"""
|
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
|
from django.http import Http404
|
|
|
|
from compensation.models import EcoAccount
|
|
from konova.views.deduction import AbstractNewDeductionView, AbstractEditDeductionView, AbstractRemoveDeductionView
|
|
|
|
_ECO_ACCOUNT_DETAIl_URL_NAME = "compensation:acc:detail"
|
|
|
|
class NewEcoAccountDeductionView(LoginRequiredMixin, AbstractNewDeductionView):
|
|
_MODEL_CLS = EcoAccount
|
|
_REDIRECT_URL = _ECO_ACCOUNT_DETAIl_URL_NAME
|
|
|
|
def _custom_check(self, obj):
|
|
# New deductions can only be created if the eco account has been recorded
|
|
if not obj.recorded:
|
|
raise Http404()
|
|
|
|
|
|
class EditEcoAccountDeductionView(LoginRequiredMixin, AbstractEditDeductionView):
|
|
_MODEL_CLS = EcoAccount
|
|
_REDIRECT_URL = _ECO_ACCOUNT_DETAIl_URL_NAME
|
|
|
|
|
|
class RemoveEcoAccountDeductionView(LoginRequiredMixin, AbstractRemoveDeductionView):
|
|
_MODEL_CLS = EcoAccount
|
|
_REDIRECT_URL = _ECO_ACCOUNT_DETAIl_URL_NAME
|