* renames certain classes to match their content * splits larger files into smaller ones
52 lines
1.8 KiB
Python
52 lines
1.8 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.models import Compensation
|
|
from konova.sub_settings.django_settings import BASE_URL
|
|
from konova.utils.qrcode import QrCode
|
|
from konova.views.report import AbstractReportView
|
|
|
|
|
|
class BaseCompensationReportView(AbstractReportView):
|
|
def _get_compensation_report_context(self, obj):
|
|
# Order states by surface
|
|
before_states = obj.before_states.all().order_by("-surface").prefetch_related("biotope_type")
|
|
after_states = obj.after_states.all().order_by("-surface").prefetch_related("biotope_type")
|
|
actions = obj.actions.all().prefetch_related("action_type")
|
|
|
|
return {
|
|
"before_states": before_states,
|
|
"after_states": after_states,
|
|
"actions": actions,
|
|
}
|
|
|
|
|
|
class CompensationReportView(BaseCompensationReportView):
|
|
_MODEL = Compensation
|
|
_TEMPLATE = "compensation/report/compensation/report.html"
|
|
|
|
def _get_report_context(self, obj):
|
|
report_url = BASE_URL + reverse("compensation:report", args=(obj.id,))
|
|
qrcode_report = QrCode(report_url, 10)
|
|
qrcode_lanis = QrCode(obj.get_LANIS_link(), 7)
|
|
|
|
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(self._get_compensation_report_context(obj))
|
|
return report_context |