Intervention views
* splits intervention/views.py (+700 lines) into separate files in new module
* view files can now be found in /intervention/views/...
This commit is contained in:
39
intervention/views/record.py
Normal file
39
intervention/views/record.py
Normal file
@@ -0,0 +1,39 @@
|
||||
"""
|
||||
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.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 intervention.models import Intervention
|
||||
from konova.decorators import conservation_office_group_required, shared_access_required
|
||||
from konova.forms.modals import RecordModalForm
|
||||
|
||||
|
||||
@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
|
||||
|
||||
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:")
|
||||
)
|
||||
Reference in New Issue
Block a user