""" 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 intervention.models import Intervention from konova.sub_settings.django_settings import BASE_URL from konova.utils.qrcode import QrCode from konova.views.report import BaseReportView class InterventionReportView(BaseReportView): _TEMPLATE = 'intervention/report/report.html' _MODEL = Intervention def _get_report_context(self, obj: Intervention): """ Returns the specific context needed for an intervention report Args: obj (Intervention): The object for the report Returns: dict: The object specific context for rendering the report """ distinct_deductions = obj.deductions.all().distinct("account") report_url = BASE_URL + reverse("intervention:report", args=(obj.id,)) qrcode_report = QrCode(report_url, 10) qrcode_lanis = QrCode(obj.get_LANIS_link(), 7) return { "deductions": distinct_deductions, "qrcode": { "img": qrcode_report.get_img(), "url": qrcode_report.get_content(), }, "qrcode_lanis": { "img": qrcode_lanis.get_img(), "url": qrcode_lanis.get_content(), }, "tables_scrollable": False, }