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