mpeltriaux
79840550cb
* splits ema/views.py (+700 lines) into separate files in new module * view files can now be found in /ema/views/...
91 lines
2.9 KiB
Python
91 lines
2.9 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.urls import reverse
|
|
|
|
from compensation.forms.modals.deadline import EditDeadlineModalForm, NewDeadlineModalForm
|
|
from ema.models import Ema
|
|
from konova.decorators import shared_access_required, conservation_office_group_required
|
|
from konova.forms.modals import RemoveDeadlineModalForm
|
|
from konova.models import Deadline
|
|
from konova.utils.message_templates import DEADLINE_REMOVED, DEADLINE_EDITED, DEADLINE_ADDED
|
|
|
|
|
|
@login_required
|
|
@conservation_office_group_required
|
|
@shared_access_required(Ema, "id")
|
|
def deadline_new_view(request: HttpRequest, id: str):
|
|
""" Renders a form for adding new states for an EMA
|
|
|
|
Args:
|
|
request (HttpRequest): The incoming request
|
|
id (str): The EMA's id to which the new state will be related
|
|
|
|
Returns:
|
|
|
|
"""
|
|
ema = get_object_or_404(Ema, id=id)
|
|
form = NewDeadlineModalForm(request.POST or None, instance=ema, request=request)
|
|
return form.process_request(
|
|
request,
|
|
msg_success=DEADLINE_ADDED,
|
|
redirect_url=reverse("ema:detail", args=(id,)) + "#related_data"
|
|
)
|
|
|
|
|
|
@login_required
|
|
@conservation_office_group_required
|
|
@shared_access_required(Ema, "id")
|
|
def deadline_edit_view(request: HttpRequest, id: str, deadline_id: str):
|
|
""" Renders a form for editing deadlines from a compensation
|
|
|
|
Args:
|
|
request (HttpRequest): The incoming request
|
|
id (str): The compensation's id
|
|
deadline_id (str): The deadline's id
|
|
|
|
Returns:
|
|
|
|
"""
|
|
ema = get_object_or_404(Ema, id=id)
|
|
deadline = get_object_or_404(Deadline, id=deadline_id)
|
|
form = EditDeadlineModalForm(request.POST or None, instance=ema, deadline=deadline, request=request)
|
|
return form.process_request(
|
|
request,
|
|
msg_success=DEADLINE_EDITED,
|
|
redirect_url=reverse("ema:detail", args=(id,)) + "#related_data"
|
|
)
|
|
|
|
|
|
@login_required
|
|
@conservation_office_group_required
|
|
@shared_access_required(Ema, "id")
|
|
def deadline_remove_view(request: HttpRequest, id: str, deadline_id: str):
|
|
""" Renders a form for removing deadlines from a compensation
|
|
|
|
Args:
|
|
request (HttpRequest): The incoming request
|
|
id (str): The compensation's id
|
|
deadline_id (str): The deadline's id
|
|
|
|
Returns:
|
|
|
|
"""
|
|
ema = get_object_or_404(Ema, id=id)
|
|
deadline = get_object_or_404(Deadline, id=deadline_id)
|
|
form = RemoveDeadlineModalForm(request.POST or None, instance=ema, deadline=deadline, request=request)
|
|
return form.process_request(
|
|
request,
|
|
msg_success=DEADLINE_REMOVED,
|
|
redirect_url=reverse("ema:detail", args=(id,)) + "#related_data"
|
|
)
|
|
|
|
|