konova/konova/views/log.py
mpeltriaux 3c416fa264 Konova views
* splits konova/views.py into separate files in new module
    * view files can now be found in /konova/views/...
* introduces first class based view AbstractLogView
    * implemented for Ema, Intervention, Compensation and EcoAccount
2022-08-19 10:25:27 +02:00

42 lines
1.1 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.shortcuts import get_object_or_404, render
from django.views import View
from django.utils.translation import gettext_lazy as _
from konova.contexts import BaseContext
class AbstractLogView(View):
model = None
class Meta:
abstract = True
def get(self, request, id: str):
""" Renders a log view using modal
Args:
request (HttpRequest): The incoming request
id (str): The compensation's id
Returns:
"""
intervention = get_object_or_404(self.model, id=id)
template = "modal/modal_generic.html"
body_template = "log.html"
context = {
"modal_body_template": body_template,
"log": intervention.log.all(),
"modal_title": _("Log"),
}
context = BaseContext(request, context).context
return render(request, template, context)