Resubmission class view
* adds AbstractResubmissionView to konova app * implemented for all major data types * replaces function based views
This commit is contained in:
parent
3c416fa264
commit
ef3507f058
@ -9,7 +9,7 @@ from django.urls import path
|
|||||||
|
|
||||||
from compensation.views.compensation.document import edit_document_view, new_document_view, remove_document_view, \
|
from compensation.views.compensation.document import edit_document_view, new_document_view, remove_document_view, \
|
||||||
get_document_view
|
get_document_view
|
||||||
from compensation.views.compensation.resubmission import create_resubmission_view
|
from compensation.views.compensation.resubmission import CompensationResubmissionView
|
||||||
from compensation.views.compensation.report import report_view
|
from compensation.views.compensation.report import report_view
|
||||||
from compensation.views.compensation.deadline import deadline_new_view, deadline_edit_view, deadline_remove_view
|
from compensation.views.compensation.deadline import deadline_new_view, deadline_edit_view, deadline_remove_view
|
||||||
from compensation.views.compensation.action import action_edit_view, action_new_view, action_remove_view
|
from compensation.views.compensation.action import action_edit_view, action_new_view, action_remove_view
|
||||||
@ -41,7 +41,7 @@ urlpatterns = [
|
|||||||
path('<id>/deadline/<deadline_id>/edit', deadline_edit_view, name='deadline-edit'),
|
path('<id>/deadline/<deadline_id>/edit', deadline_edit_view, name='deadline-edit'),
|
||||||
path('<id>/deadline/<deadline_id>/remove', deadline_remove_view, name='deadline-remove'),
|
path('<id>/deadline/<deadline_id>/remove', deadline_remove_view, name='deadline-remove'),
|
||||||
path('<id>/report', report_view, name='report'),
|
path('<id>/report', report_view, name='report'),
|
||||||
path('<id>/resub', create_resubmission_view, name='resubmission-create'),
|
path('<id>/resub', CompensationResubmissionView.as_view(), name='resubmission-create'),
|
||||||
|
|
||||||
# Documents
|
# Documents
|
||||||
path('<id>/document/new/', new_document_view, name='new-doc'),
|
path('<id>/document/new/', new_document_view, name='new-doc'),
|
||||||
|
@ -13,7 +13,7 @@ from compensation.views.eco_account.eco_account import index_view, new_view, new
|
|||||||
from compensation.views.eco_account.log import EcoAccountLogView
|
from compensation.views.eco_account.log import EcoAccountLogView
|
||||||
from compensation.views.eco_account.record import record_view
|
from compensation.views.eco_account.record import record_view
|
||||||
from compensation.views.eco_account.report import report_view
|
from compensation.views.eco_account.report import report_view
|
||||||
from compensation.views.eco_account.resubmission import create_resubmission_view
|
from compensation.views.eco_account.resubmission import EcoAccountResubmissionView
|
||||||
from compensation.views.eco_account.state import state_new_view, state_remove_view, state_edit_view
|
from compensation.views.eco_account.state import state_new_view, state_remove_view, state_edit_view
|
||||||
from compensation.views.eco_account.action import action_edit_view, action_new_view, action_remove_view
|
from compensation.views.eco_account.action import action_edit_view, action_new_view, action_remove_view
|
||||||
from compensation.views.eco_account.deadline import deadline_new_view, deadline_edit_view, deadline_remove_view
|
from compensation.views.eco_account.deadline import deadline_new_view, deadline_edit_view, deadline_remove_view
|
||||||
@ -33,7 +33,7 @@ urlpatterns = [
|
|||||||
path('<id>/report', report_view, name='report'),
|
path('<id>/report', report_view, name='report'),
|
||||||
path('<id>/edit', edit_view, name='edit'),
|
path('<id>/edit', edit_view, name='edit'),
|
||||||
path('<id>/remove', remove_view, name='remove'),
|
path('<id>/remove', remove_view, name='remove'),
|
||||||
path('<id>/resub', create_resubmission_view, name='resubmission-create'),
|
path('<id>/resub', EcoAccountResubmissionView.as_view(), name='resubmission-create'),
|
||||||
|
|
||||||
path('<id>/state/new', state_new_view, name='new-state'),
|
path('<id>/state/new', state_new_view, name='new-state'),
|
||||||
path('<id>/state/<state_id>/edit', state_edit_view, name='state-edit'),
|
path('<id>/state/<state_id>/edit', state_edit_view, name='state-edit'),
|
||||||
|
@ -6,34 +6,20 @@ Created on: 19.08.22
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.http import HttpRequest
|
from django.utils.decorators import method_decorator
|
||||||
from django.shortcuts import get_object_or_404
|
|
||||||
from django.urls import reverse
|
|
||||||
from django.utils.translation import gettext_lazy as _
|
|
||||||
|
|
||||||
from compensation.models import Compensation
|
from compensation.models import Compensation
|
||||||
from konova.decorators import shared_access_required, default_group_required
|
from konova.decorators import shared_access_required, default_group_required
|
||||||
from konova.forms.modals import ResubmissionModalForm
|
from konova.views.resubmission import AbstractResubmissionView
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
class CompensationResubmissionView(AbstractResubmissionView):
|
||||||
@default_group_required
|
model = Compensation
|
||||||
@shared_access_required(Compensation, "id")
|
redirect_url_base = "compensation:detail"
|
||||||
def create_resubmission_view(request: HttpRequest, id: str):
|
form_action_url_base = "compensation:resubmission-create"
|
||||||
""" Renders resubmission form for a compensation
|
|
||||||
|
|
||||||
Args:
|
@method_decorator(login_required)
|
||||||
request (HttpRequest): The incoming request
|
@method_decorator(default_group_required)
|
||||||
id (str): Compensation's id
|
@method_decorator(shared_access_required(Compensation, "id"))
|
||||||
|
def dispatch(self, request, *args, **kwargs):
|
||||||
Returns:
|
return super().dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
"""
|
|
||||||
com = get_object_or_404(Compensation, id=id)
|
|
||||||
form = ResubmissionModalForm(request.POST or None, instance=com, request=request)
|
|
||||||
form.action_url = reverse("compensation:resubmission-create", args=(id,))
|
|
||||||
return form.process_request(
|
|
||||||
request,
|
|
||||||
msg_success=_("Resubmission set"),
|
|
||||||
redirect_url=reverse("compensation:detail", args=(id,))
|
|
||||||
)
|
|
||||||
|
@ -6,34 +6,20 @@ Created on: 19.08.22
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.http import HttpRequest
|
from django.utils.decorators import method_decorator
|
||||||
from django.shortcuts import get_object_or_404
|
|
||||||
from django.urls import reverse
|
|
||||||
from django.utils.translation import gettext_lazy as _
|
|
||||||
|
|
||||||
from compensation.models import EcoAccount
|
from compensation.models import EcoAccount
|
||||||
from konova.decorators import shared_access_required, default_group_required
|
from konova.decorators import shared_access_required, default_group_required
|
||||||
from konova.forms.modals import ResubmissionModalForm
|
from konova.views.resubmission import AbstractResubmissionView
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
class EcoAccountResubmissionView(AbstractResubmissionView):
|
||||||
@default_group_required
|
model = EcoAccount
|
||||||
@shared_access_required(EcoAccount, "id")
|
redirect_url_base = "compensation:acc:detail"
|
||||||
def create_resubmission_view(request: HttpRequest, id: str):
|
form_action_url_base = "compensation:acc:resubmission-create"
|
||||||
""" Renders resubmission form for an eco account
|
|
||||||
|
|
||||||
Args:
|
@method_decorator(login_required)
|
||||||
request (HttpRequest): The incoming request
|
@method_decorator(default_group_required)
|
||||||
id (str): EcoAccount's id
|
@method_decorator(shared_access_required(EcoAccount, "id"))
|
||||||
|
def dispatch(self, request, *args, **kwargs):
|
||||||
Returns:
|
return super().dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
"""
|
|
||||||
acc = get_object_or_404(EcoAccount, id=id)
|
|
||||||
form = ResubmissionModalForm(request.POST or None, instance=acc, request=request)
|
|
||||||
form.action_url = reverse("compensation:acc:resubmission-create", args=(id,))
|
|
||||||
return form.process_request(
|
|
||||||
request,
|
|
||||||
msg_success=_("Resubmission set"),
|
|
||||||
redirect_url=reverse("compensation:acc:detail", args=(id,))
|
|
||||||
)
|
|
||||||
|
@ -14,7 +14,7 @@ from ema.views.ema import index_view, new_view, new_id_view, detail_view, edit_v
|
|||||||
from ema.views.log import EmaLogView
|
from ema.views.log import EmaLogView
|
||||||
from ema.views.record import record_view
|
from ema.views.record import record_view
|
||||||
from ema.views.report import report_view
|
from ema.views.report import report_view
|
||||||
from ema.views.resubmission import create_resubmission_view
|
from ema.views.resubmission import EmaResubmissionView
|
||||||
from ema.views.share import share_view, create_share_view
|
from ema.views.share import share_view, create_share_view
|
||||||
from ema.views.state import state_new_view, state_remove_view, state_edit_view
|
from ema.views.state import state_new_view, state_remove_view, state_edit_view
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ urlpatterns = [
|
|||||||
path('<id>/remove', remove_view, name='remove'),
|
path('<id>/remove', remove_view, name='remove'),
|
||||||
path('<id>/record', record_view, name='record'),
|
path('<id>/record', record_view, name='record'),
|
||||||
path('<id>/report', report_view, name='report'),
|
path('<id>/report', report_view, name='report'),
|
||||||
path('<id>/resub', create_resubmission_view, name='resubmission-create'),
|
path('<id>/resub', EmaResubmissionView.as_view(), name='resubmission-create'),
|
||||||
|
|
||||||
path('<id>/state/new', state_new_view, name='new-state'),
|
path('<id>/state/new', state_new_view, name='new-state'),
|
||||||
path('<id>/state/<state_id>/remove', state_remove_view, name='state-remove'),
|
path('<id>/state/<state_id>/remove', state_remove_view, name='state-remove'),
|
||||||
|
@ -6,34 +6,20 @@ Created on: 19.08.22
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.http import HttpRequest
|
from django.utils.decorators import method_decorator
|
||||||
from django.shortcuts import get_object_or_404
|
|
||||||
from django.urls import reverse
|
|
||||||
from django.utils.translation import gettext_lazy as _
|
|
||||||
|
|
||||||
from ema.models import Ema
|
from ema.models import Ema
|
||||||
from konova.decorators import shared_access_required, conservation_office_group_required
|
from konova.decorators import shared_access_required, conservation_office_group_required
|
||||||
from konova.forms.modals import ResubmissionModalForm
|
from konova.views.resubmission import AbstractResubmissionView
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
class EmaResubmissionView(AbstractResubmissionView):
|
||||||
@conservation_office_group_required
|
model = Ema
|
||||||
@shared_access_required(Ema, "id")
|
redirect_url_base = "ema:detail"
|
||||||
def create_resubmission_view(request: HttpRequest, id: str):
|
form_action_url_base = "ema:resubmission-create"
|
||||||
""" Renders resubmission form for an EMA
|
|
||||||
|
|
||||||
Args:
|
@method_decorator(login_required)
|
||||||
request (HttpRequest): The incoming request
|
@method_decorator(conservation_office_group_required)
|
||||||
id (str): EMA's id
|
@method_decorator(shared_access_required(Ema, "id"))
|
||||||
|
def dispatch(self, request, *args, **kwargs):
|
||||||
Returns:
|
return super().dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
"""
|
|
||||||
ema = get_object_or_404(Ema, id=id)
|
|
||||||
form = ResubmissionModalForm(request.POST or None, instance=ema, request=request)
|
|
||||||
form.action_url = reverse("ema:resubmission-create", args=(id,))
|
|
||||||
return form.process_request(
|
|
||||||
request,
|
|
||||||
msg_success=_("Resubmission set"),
|
|
||||||
redirect_url=reverse("ema:detail", args=(id,))
|
|
||||||
)
|
|
||||||
|
@ -16,7 +16,7 @@ from intervention.views.intervention import index_view, new_view, new_id_view, d
|
|||||||
from intervention.views.log import InterventionLogView
|
from intervention.views.log import InterventionLogView
|
||||||
from intervention.views.record import record_view
|
from intervention.views.record import record_view
|
||||||
from intervention.views.report import report_view
|
from intervention.views.report import report_view
|
||||||
from intervention.views.resubmission import create_resubmission_view
|
from intervention.views.resubmission import InterventionResubmissionView
|
||||||
from intervention.views.revocation import new_revocation_view, edit_revocation_view, remove_revocation_view, \
|
from intervention.views.revocation import new_revocation_view, edit_revocation_view, remove_revocation_view, \
|
||||||
get_revocation_view
|
get_revocation_view
|
||||||
from intervention.views.share import share_view, create_share_view
|
from intervention.views.share import share_view, create_share_view
|
||||||
@ -35,7 +35,7 @@ urlpatterns = [
|
|||||||
path('<id>/check', check_view, name='check'),
|
path('<id>/check', check_view, name='check'),
|
||||||
path('<id>/record', record_view, name='record'),
|
path('<id>/record', record_view, name='record'),
|
||||||
path('<id>/report', report_view, name='report'),
|
path('<id>/report', report_view, name='report'),
|
||||||
path('<id>/resub', create_resubmission_view, name='resubmission-create'),
|
path('<id>/resub', InterventionResubmissionView.as_view(), name='resubmission-create'),
|
||||||
|
|
||||||
# Compensations
|
# Compensations
|
||||||
path('<id>/compensation/<comp_id>/remove', remove_compensation_view, name='remove-compensation'),
|
path('<id>/compensation/<comp_id>/remove', remove_compensation_view, name='remove-compensation'),
|
||||||
|
@ -6,34 +6,20 @@ Created on: 19.08.22
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.http import HttpRequest
|
from django.utils.decorators import method_decorator
|
||||||
from django.shortcuts import get_object_or_404
|
|
||||||
from django.urls import reverse
|
|
||||||
from django.utils.translation import gettext_lazy as _
|
|
||||||
|
|
||||||
from intervention.models import Intervention
|
from intervention.models import Intervention
|
||||||
from konova.decorators import default_group_required, shared_access_required
|
from konova.decorators import default_group_required, shared_access_required
|
||||||
from konova.forms.modals import ResubmissionModalForm
|
from konova.views.resubmission import AbstractResubmissionView
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
class InterventionResubmissionView(AbstractResubmissionView):
|
||||||
@default_group_required
|
model = Intervention
|
||||||
@shared_access_required(Intervention, "id")
|
redirect_url_base = "intervention:detail"
|
||||||
def create_resubmission_view(request: HttpRequest, id: str):
|
form_action_url_base = "intervention:resubmission-create"
|
||||||
""" Renders resubmission form for an intervention
|
|
||||||
|
|
||||||
Args:
|
@method_decorator(login_required)
|
||||||
request (HttpRequest): The incoming request
|
@method_decorator(default_group_required)
|
||||||
id (str): Intervention's id
|
@method_decorator(shared_access_required(Intervention, "id"))
|
||||||
|
def dispatch(self, request, *args, **kwargs):
|
||||||
Returns:
|
return super().dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
"""
|
|
||||||
intervention = get_object_or_404(Intervention, id=id)
|
|
||||||
form = ResubmissionModalForm(request.POST or None, instance=intervention, request=request)
|
|
||||||
form.action_url = reverse("intervention:resubmission-create", args=(id,))
|
|
||||||
return form.process_request(
|
|
||||||
request,
|
|
||||||
msg_success=_("Resubmission set"),
|
|
||||||
redirect_url=reverse("intervention:detail", args=(id,))
|
|
||||||
)
|
|
||||||
|
55
konova/views/resubmission.py
Normal file
55
konova/views/resubmission.py
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
"""
|
||||||
|
Author: Michel Peltriaux
|
||||||
|
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
|
||||||
|
Contact: ksp-servicestelle@sgdnord.rlp.de
|
||||||
|
Created on: 19.08.22
|
||||||
|
|
||||||
|
"""
|
||||||
|
from django.shortcuts import get_object_or_404
|
||||||
|
from django.urls import reverse
|
||||||
|
from django.views import View
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
from konova.forms.modals import ResubmissionModalForm
|
||||||
|
|
||||||
|
|
||||||
|
class AbstractResubmissionView(View):
|
||||||
|
model = None
|
||||||
|
form_action_url_base = None
|
||||||
|
redirect_url_base = None
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
abstract = True
|
||||||
|
|
||||||
|
def get(self, request, id: str):
|
||||||
|
""" Renders resubmission form for an intervention
|
||||||
|
|
||||||
|
Args:
|
||||||
|
request (HttpRequest): The incoming request
|
||||||
|
id (str): Intervention's id
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
"""
|
||||||
|
obj = get_object_or_404(self.model, id=id)
|
||||||
|
form = ResubmissionModalForm(request.POST or None, instance=obj, request=request)
|
||||||
|
form.action_url = reverse(self.form_action_url_base, args=(id,))
|
||||||
|
return form.process_request(
|
||||||
|
request,
|
||||||
|
msg_success=_("Resubmission set"),
|
||||||
|
redirect_url=reverse(self.redirect_url_base, args=(id,))
|
||||||
|
)
|
||||||
|
|
||||||
|
def post(self, request, id: str):
|
||||||
|
"""
|
||||||
|
|
||||||
|
BaseModalForm provides the method process_request() which handles GET as well as POST requests. It was written
|
||||||
|
for easier handling of function based views. To support process_request() on class based views, the post()
|
||||||
|
call needs to be treated the same way as the get() call.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
request (HttpRequest): The incoming request
|
||||||
|
id (str): Intervention's id
|
||||||
|
|
||||||
|
"""
|
||||||
|
return self.get(request, id)
|
Loading…
Reference in New Issue
Block a user