konova/compensation/views/eco_account/record.py
mpeltriaux d168ec47ce EcoAccount views
* 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/...
2022-08-19 08:27:42 +02:00

39 lines
1.2 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 compensation.models import EcoAccount
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(EcoAccount, "id")
def record_view(request: HttpRequest, id:str):
""" Renders a modal form for recording an eco account
Args:
request (HttpRequest): The incoming request
id (str): The account's id
Returns:
"""
acc = get_object_or_404(EcoAccount, id=id)
form = RecordModalForm(request.POST or None, instance=acc, request=request)
msg_succ = _("{} unrecorded") if acc.recorded else _("{} recorded")
msg_succ = msg_succ.format(acc.identifier)
return form.process_request(
request,
msg_succ
)