* refactors remove view for kom, eiv, oek and ema * introduces BaseRemoveModalFormView * moves html blocking logic from BaseModalForm into BaseModalFormView
38 lines
1.3 KiB
Python
38 lines
1.3 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()
|
|
|
|
def _check_for_recorded_instance(self, obj):
|
|
# Deductions can be created on recorded as well as on non-recorded entries
|
|
return None
|
|
|
|
|
|
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
|