You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
konova/intervention/views/record.py

40 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.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:")
)