EMA views
* splits ema/views.py (+700 lines) into separate files in new module
* view files can now be found in /ema/views/...
This commit is contained in:
37
ema/views/record.py
Normal file
37
ema/views/record.py
Normal file
@@ -0,0 +1,37 @@
|
||||
"""
|
||||
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 ema.models import Ema
|
||||
from konova.decorators import shared_access_required, conservation_office_group_required
|
||||
from konova.forms.modals import RecordModalForm
|
||||
|
||||
|
||||
@login_required
|
||||
@conservation_office_group_required
|
||||
@shared_access_required(Ema, "id")
|
||||
def record_view(request: HttpRequest, id: str):
|
||||
""" Renders a modal view for recording the EMA
|
||||
|
||||
Args:
|
||||
request (HttpRequest): The incoming request
|
||||
id (str): The EMA's id
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
ema = get_object_or_404(Ema, id=id)
|
||||
msg_succ = _("{} unrecorded") if ema.recorded else _("{} recorded")
|
||||
form = RecordModalForm(request.POST or None, instance=ema, request=request)
|
||||
return form.process_request(
|
||||
request=request,
|
||||
msg_success=msg_succ.format("EMA"),
|
||||
)
|
||||
Reference in New Issue
Block a user