Record class view

* adds AbstractRecordView to konova/views/record.py
    * implements for all major data types
This commit is contained in:
2022-08-19 11:01:33 +02:00
parent 096385a9eb
commit c80145366e
9 changed files with 86 additions and 81 deletions

View File

@@ -14,7 +14,7 @@ from intervention.views.deduction import new_deduction_view, edit_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 InterventionLogView
from intervention.views.record import record_view
from intervention.views.record import InterventionRecordView
from intervention.views.report import report_view
from intervention.views.resubmission import InterventionResubmissionView
from intervention.views.revocation import new_revocation_view, edit_revocation_view, remove_revocation_view, \
@@ -33,7 +33,7 @@ urlpatterns = [
path('<id>/share/<token>', share_view, name='share'),
path('<id>/share', create_share_view, name='share-create'),
path('<id>/check', check_view, name='check'),
path('<id>/record', record_view, name='record'),
path('<id>/record', InterventionRecordView.as_view(), name='record'),
path('<id>/report', report_view, name='report'),
path('<id>/resub', InterventionResubmissionView.as_view(), name='resubmission-create'),

View File

@@ -6,34 +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
from django.utils.translation import gettext_lazy as _
from django.utils.decorators import method_decorator
from intervention.models import Intervention
from konova.decorators import conservation_office_group_required, shared_access_required
from konova.forms.modals import RecordModalForm
from konova.views.record import AbstractRecordView
@login_required
@conservation_office_group_required
@shared_access_required(Intervention, "id")
def record_view(request: HttpRequest, id: str):
""" Renders a modal form for recording an intervention
class InterventionRecordView(AbstractRecordView):
model = Intervention
Args:
request (HttpRequest): The incoming request
id (str): The intervention's id
Returns:
"""
intervention = get_object_or_404(Intervention, id=id)
form = RecordModalForm(request.POST or None, instance=intervention, request=request)
msg_succ = _("{} unrecorded") if intervention.recorded else _("{} recorded")
msg_succ = msg_succ.format(intervention.identifier)
return form.process_request(
request,
msg_succ,
msg_error=_("There are errors on this intervention:")
)
@method_decorator(login_required)
@method_decorator(conservation_office_group_required)
@method_decorator(shared_access_required(Intervention, "id"))
def dispatch(self, request, *args, **kwargs):
return super().dispatch(request, *args, **kwargs)