#25 Public reports

* adds fully functional EMA report
* adds/updates translations
This commit is contained in:
2021-10-14 08:49:32 +02:00
parent f894d6d4c5
commit fac6be0a8a
6 changed files with 142 additions and 40 deletions
+15 -1
View File
@@ -412,7 +412,7 @@ def report_view(request:HttpRequest, id: str):
"""
# Reuse the compensation report template since EMAs are structurally identical
template = "compensation/report/report.html"
template = "ema/report/report.html"
ema = get_object_or_404(Ema, id=id)
# If intervention is not recorded (yet or currently) we need to render another template without any data
@@ -420,6 +420,10 @@ def report_view(request:HttpRequest, id: str):
template = "report/unavailable.html"
return render(request, template, {})
# Prepare data for map viewer
geom_form = SimpleGeomForm(
instance=ema
)
qrcode_img = generate_qr_code(
request.build_absolute_uri(reverse("ema:report", args=(id,))),
10
@@ -428,10 +432,20 @@ def report_view(request:HttpRequest, id: str):
ema.get_LANIS_link(),
7
)
# Order states by surface
before_states = ema.before_states.all().order_by("-surface").prefetch_related("biotope_type")
after_states = ema.after_states.all().order_by("-surface").prefetch_related("biotope_type")
actions = ema.actions.all().prefetch_related("action_type")
context = {
"obj": ema,
"qrcode": qrcode_img,
"qrcode_lanis": qrcode_img_lanis,
"has_access": False, # disables action buttons during rendering
"before_states": before_states,
"after_states": after_states,
"geom_form": geom_form,
"actions": actions,
}
context = BaseContext(request, context).context
return render(request, template, context)