konova/ema/views/report.py
mpeltriaux f2baa054bf # Report view refactoring
* refactors function based report views into class based for EIV, OEK, EMA, KOM
* introduces BaseReportView for proper inheritance of shared logic
* refactors generating of qr codes into proper class
2025-10-17 11:07:16 +02:00

40 lines
1.3 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.urls import reverse
from compensation.views.compensation.report import BaseCompensationReportView
from ema.models import Ema
from konova.sub_settings.django_settings import BASE_URL
from konova.utils.qrcode import QrCode
class EmaReportView(BaseCompensationReportView):
_TEMPLATE = "ema/report/report.html"
_MODEL = Ema
def _get_report_context(self, obj):
report_url = BASE_URL + reverse("ema:report", args=(obj.id,))
qrcode_report = QrCode(report_url, 10)
qrcode_lanis = QrCode(obj.get_LANIS_link(), 7)
generic_compensation_report_context = self._get_compensation_report_context(obj)
report_context = {
"qrcode": {
"img": qrcode_report.get_img(),
"url": qrcode_report.get_content(),
},
"qrcode_lanis": {
"img": qrcode_lanis.get_img(),
"url": qrcode_lanis.get_content(),
},
"is_entry_shared": False, # disables action buttons during rendering
"tables_scrollable": False,
}
report_context.update(generic_compensation_report_context)
return report_context