Konova views
* splits konova/views.py into separate files in new module
* view files can now be found in /konova/views/...
* introduces first class based view AbstractLogView
* implemented for Ema, Intervention, Compensation and EcoAccount
This commit is contained in:
@@ -13,7 +13,7 @@ from intervention.views.compensation import remove_compensation_view
|
||||
from intervention.views.deduction import new_deduction_view, edit_deduction_view, remove_deduction_view
|
||||
from intervention.views.document import new_document_view, get_document_view, remove_document_view, edit_document_view
|
||||
from intervention.views.intervention import index_view, new_view, new_id_view, detail_view, edit_view, remove_view
|
||||
from intervention.views.log import log_view
|
||||
from intervention.views.log import InterventionLogView
|
||||
from intervention.views.record import record_view
|
||||
from intervention.views.report import report_view
|
||||
from intervention.views.resubmission import create_resubmission_view
|
||||
@@ -27,7 +27,7 @@ urlpatterns = [
|
||||
path('new/', new_view, name='new'),
|
||||
path('new/id', new_id_view, name='new-id'),
|
||||
path('<id>', detail_view, name='detail'),
|
||||
path('<id>/log', log_view, name='log'),
|
||||
path('<id>/log', InterventionLogView.as_view(), name='log'),
|
||||
path('<id>/edit', edit_view, name='edit'),
|
||||
path('<id>/remove', remove_view, name='remove'),
|
||||
path('<id>/share/<token>', share_view, name='share'),
|
||||
|
||||
@@ -6,36 +6,18 @@ Created on: 19.08.22
|
||||
|
||||
"""
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.http import HttpRequest
|
||||
from django.shortcuts import get_object_or_404, render
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils.decorators import method_decorator
|
||||
|
||||
from intervention.models import Intervention
|
||||
from konova.contexts import BaseContext
|
||||
from konova.decorators import shared_access_required, default_group_required
|
||||
from konova.views.log import AbstractLogView
|
||||
|
||||
|
||||
@login_required
|
||||
@default_group_required
|
||||
@shared_access_required(Intervention, "id")
|
||||
def log_view(request: HttpRequest, id: str):
|
||||
""" Renders a log view using modal
|
||||
class InterventionLogView(AbstractLogView):
|
||||
model = Intervention
|
||||
|
||||
Args:
|
||||
request (HttpRequest): The incoming request
|
||||
id (str): The compensation's id
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
intervention = get_object_or_404(Intervention, id=id)
|
||||
template = "modal/modal_generic.html"
|
||||
body_template = "log.html"
|
||||
|
||||
context = {
|
||||
"modal_body_template": body_template,
|
||||
"log": intervention.log.all(),
|
||||
"modal_title": _("Log"),
|
||||
}
|
||||
context = BaseContext(request, context).context
|
||||
return render(request, template, context)
|
||||
@method_decorator(login_required)
|
||||
@method_decorator(default_group_required)
|
||||
@method_decorator(shared_access_required(Intervention, "id"))
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
Reference in New Issue
Block a user