#146 Clickable QR codes
* refactors QR codes on report views to be clickable as well (even supported through saved pdf)
This commit is contained in:
parent
23b6130907
commit
25d2b806ab
@ -41,14 +41,7 @@
|
|||||||
{% include 'konova/includes/parcels.html' %}
|
{% include 'konova/includes/parcels.html' %}
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-6 col-md-6 col-lg-6">
|
{% include 'konova/includes/report/qrcodes.html' %}
|
||||||
<h4>{% trans 'Open in browser' %}</h4>
|
|
||||||
{{ qrcode|safe }}
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-6 col-md-6 col-lg-6">
|
|
||||||
<h4>{% trans 'View in LANIS' %}</h4>
|
|
||||||
{{ qrcode_lanis|safe }}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -54,14 +54,7 @@
|
|||||||
{% include 'konova/includes/parcels.html' %}
|
{% include 'konova/includes/parcels.html' %}
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-6 col-md-6 col-lg-6">
|
{% include 'konova/includes/report/qrcodes.html' %}
|
||||||
<h4>{% trans 'Open in browser' %}</h4>
|
|
||||||
{{ qrcode|safe }}
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-6 col-md-6 col-lg-6">
|
|
||||||
<h4>{% trans 'View in LANIS' %}</h4>
|
|
||||||
{{ qrcode_lanis|safe }}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -596,14 +596,12 @@ def report_view(request: HttpRequest, id: str):
|
|||||||
instance=comp
|
instance=comp
|
||||||
)
|
)
|
||||||
parcels = comp.get_underlying_parcels()
|
parcels = comp.get_underlying_parcels()
|
||||||
qrcode_img = generate_qr_code(
|
|
||||||
request.build_absolute_uri(reverse("compensation:report", args=(id,))),
|
qrcode_url = request.build_absolute_uri(reverse("compensation:report", args=(id,)))
|
||||||
10
|
qrcode_img = generate_qr_code(qrcode_url, 10)
|
||||||
)
|
qrcode_lanis_url = comp.get_LANIS_link()
|
||||||
qrcode_img_lanis = generate_qr_code(
|
qrcode_img_lanis = generate_qr_code(qrcode_lanis_url, 7)
|
||||||
comp.get_LANIS_link(),
|
|
||||||
7
|
|
||||||
)
|
|
||||||
# Order states by surface
|
# Order states by surface
|
||||||
before_states = comp.before_states.all().order_by("-surface").prefetch_related("biotope_type")
|
before_states = comp.before_states.all().order_by("-surface").prefetch_related("biotope_type")
|
||||||
after_states = comp.after_states.all().order_by("-surface").prefetch_related("biotope_type")
|
after_states = comp.after_states.all().order_by("-surface").prefetch_related("biotope_type")
|
||||||
@ -611,8 +609,14 @@ def report_view(request: HttpRequest, id: str):
|
|||||||
|
|
||||||
context = {
|
context = {
|
||||||
"obj": comp,
|
"obj": comp,
|
||||||
"qrcode": qrcode_img,
|
"qrcode": {
|
||||||
"qrcode_lanis": qrcode_img_lanis,
|
"img": qrcode_img,
|
||||||
|
"url": qrcode_url,
|
||||||
|
},
|
||||||
|
"qrcode_lanis": {
|
||||||
|
"img": qrcode_img_lanis,
|
||||||
|
"url": qrcode_lanis_url,
|
||||||
|
},
|
||||||
"has_access": False, # disables action buttons during rendering
|
"has_access": False, # disables action buttons during rendering
|
||||||
"before_states": before_states,
|
"before_states": before_states,
|
||||||
"after_states": after_states,
|
"after_states": after_states,
|
||||||
|
@ -731,18 +731,16 @@ def report_view(request:HttpRequest, id: str):
|
|||||||
instance=acc
|
instance=acc
|
||||||
)
|
)
|
||||||
parcels = acc.get_underlying_parcels()
|
parcels = acc.get_underlying_parcels()
|
||||||
qrcode_img = generate_qr_code(
|
|
||||||
request.build_absolute_uri(reverse("ema:report", args=(id,))),
|
qrcode_url = request.build_absolute_uri(reverse("ema:report", args=(id,)))
|
||||||
10
|
qrcode_img = generate_qr_code(qrcode_url, 10)
|
||||||
)
|
qrcode_lanis_url = acc.get_LANIS_link()
|
||||||
qrcode_img_lanis = generate_qr_code(
|
qrcode_img_lanis = generate_qr_code(qrcode_lanis_url, 7)
|
||||||
acc.get_LANIS_link(),
|
|
||||||
7
|
|
||||||
)
|
|
||||||
# Order states by surface
|
# Order states by surface
|
||||||
before_states = acc.before_states.all().order_by("-surface").select_related("biotope_type__parent")
|
before_states = acc.before_states.all().order_by("-surface").select_related("biotope_type__parent")
|
||||||
after_states = acc.after_states.all().order_by("-surface").select_related("biotope_type__parent")
|
after_states = acc.after_states.all().order_by("-surface").select_related("biotope_type__parent")
|
||||||
actions = acc.actions.all().select_related("action_type__parent")
|
actions = acc.actions.all().prefetch_related("action_type__parent")
|
||||||
|
|
||||||
# Reduce amount of db fetched data to the bare minimum we need in the template (deduction's intervention id and identifier)
|
# Reduce amount of db fetched data to the bare minimum we need in the template (deduction's intervention id and identifier)
|
||||||
deductions = acc.deductions.all()\
|
deductions = acc.deductions.all()\
|
||||||
@ -752,8 +750,14 @@ def report_view(request:HttpRequest, id: str):
|
|||||||
|
|
||||||
context = {
|
context = {
|
||||||
"obj": acc,
|
"obj": acc,
|
||||||
"qrcode": qrcode_img,
|
"qrcode": {
|
||||||
"qrcode_lanis": qrcode_img_lanis,
|
"img": qrcode_img,
|
||||||
|
"url": qrcode_url,
|
||||||
|
},
|
||||||
|
"qrcode_lanis": {
|
||||||
|
"img": qrcode_img_lanis,
|
||||||
|
"url": qrcode_lanis_url,
|
||||||
|
},
|
||||||
"has_access": False, # disables action buttons during rendering
|
"has_access": False, # disables action buttons during rendering
|
||||||
"before_states": before_states,
|
"before_states": before_states,
|
||||||
"after_states": after_states,
|
"after_states": after_states,
|
||||||
|
@ -41,14 +41,7 @@
|
|||||||
{% include 'konova/includes/parcels.html' %}
|
{% include 'konova/includes/parcels.html' %}
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-6 col-md-6 col-lg-6">
|
{% include 'konova/includes/report/qrcodes.html' %}
|
||||||
<h4>{% trans 'Open in browser' %}</h4>
|
|
||||||
{{ qrcode|safe }}
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-6 col-md-6 col-lg-6">
|
|
||||||
<h4>{% trans 'View in LANIS' %}</h4>
|
|
||||||
{{ qrcode_lanis|safe }}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
24
ema/views.py
24
ema/views.py
@ -563,14 +563,12 @@ def report_view(request:HttpRequest, id: str):
|
|||||||
instance=ema,
|
instance=ema,
|
||||||
)
|
)
|
||||||
parcels = ema.get_underlying_parcels()
|
parcels = ema.get_underlying_parcels()
|
||||||
qrcode_img = generate_qr_code(
|
|
||||||
request.build_absolute_uri(reverse("ema:report", args=(id,))),
|
qrcode_url = request.build_absolute_uri(reverse("ema:report", args=(id,)))
|
||||||
10
|
qrcode_img = generate_qr_code(qrcode_url, 10)
|
||||||
)
|
qrcode_lanis_url = ema.get_LANIS_link()
|
||||||
qrcode_img_lanis = generate_qr_code(
|
qrcode_img_lanis = generate_qr_code(qrcode_lanis_url, 7)
|
||||||
ema.get_LANIS_link(),
|
|
||||||
7
|
|
||||||
)
|
|
||||||
# Order states by surface
|
# Order states by surface
|
||||||
before_states = ema.before_states.all().order_by("-surface").prefetch_related("biotope_type")
|
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")
|
after_states = ema.after_states.all().order_by("-surface").prefetch_related("biotope_type")
|
||||||
@ -578,8 +576,14 @@ def report_view(request:HttpRequest, id: str):
|
|||||||
|
|
||||||
context = {
|
context = {
|
||||||
"obj": ema,
|
"obj": ema,
|
||||||
"qrcode": qrcode_img,
|
"qrcode": {
|
||||||
"qrcode_lanis": qrcode_img_lanis,
|
"img": qrcode_img,
|
||||||
|
"url": qrcode_url
|
||||||
|
},
|
||||||
|
"qrcode_lanis": {
|
||||||
|
"img": qrcode_img_lanis,
|
||||||
|
"url": qrcode_lanis_url
|
||||||
|
},
|
||||||
"has_access": False, # disables action buttons during rendering
|
"has_access": False, # disables action buttons during rendering
|
||||||
"before_states": before_states,
|
"before_states": before_states,
|
||||||
"after_states": after_states,
|
"after_states": after_states,
|
||||||
|
@ -100,14 +100,7 @@
|
|||||||
{% include 'konova/includes/parcels.html' %}
|
{% include 'konova/includes/parcels.html' %}
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-6 col-md-6 col-lg-6">
|
{% include 'konova/includes/report/qrcodes.html' %}
|
||||||
<h4>{% trans 'Open in browser' %}</h4>
|
|
||||||
{{ qrcode|safe }}
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-6 col-md-6 col-lg-6">
|
|
||||||
<h4>{% trans 'View in LANIS' %}</h4>
|
|
||||||
{{ qrcode_lanis|safe }}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -693,19 +693,22 @@ def report_view(request:HttpRequest, id: str):
|
|||||||
distinct_deductions = intervention.deductions.all().distinct(
|
distinct_deductions = intervention.deductions.all().distinct(
|
||||||
"account"
|
"account"
|
||||||
)
|
)
|
||||||
qrcode_img = generate_qr_code(
|
qrcode_url = request.build_absolute_uri(reverse("intervention:report", args=(id,)))
|
||||||
request.build_absolute_uri(reverse("intervention:report", args=(id,))),
|
qrcode_img = generate_qr_code(qrcode_url, 10)
|
||||||
10
|
qrcode_lanis_url = intervention.get_LANIS_link()
|
||||||
)
|
qrcode_img_lanis = generate_qr_code(qrcode_lanis_url, 7)
|
||||||
qrcode_img_lanis = generate_qr_code(
|
|
||||||
intervention.get_LANIS_link(),
|
|
||||||
7
|
|
||||||
)
|
|
||||||
context = {
|
context = {
|
||||||
"obj": intervention,
|
"obj": intervention,
|
||||||
"deductions": distinct_deductions,
|
"deductions": distinct_deductions,
|
||||||
"qrcode": qrcode_img,
|
"qrcode": {
|
||||||
"qrcode_lanis": qrcode_img_lanis,
|
"img": qrcode_img,
|
||||||
|
"url": qrcode_url,
|
||||||
|
},
|
||||||
|
"qrcode_lanis": {
|
||||||
|
"img": qrcode_img_lanis,
|
||||||
|
"url": qrcode_lanis_url,
|
||||||
|
},
|
||||||
"geom_form": geom_form,
|
"geom_form": geom_form,
|
||||||
"parcels": parcels,
|
"parcels": parcels,
|
||||||
TAB_TITLE_IDENTIFIER: tab_title,
|
TAB_TITLE_IDENTIFIER: tab_title,
|
||||||
|
19
konova/templates/konova/includes/report/qrcodes.html
Normal file
19
konova/templates/konova/includes/report/qrcodes.html
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
|
||||||
|
<div class="col-sm-6 col-md-6 col-lg-6">
|
||||||
|
<button class="btn btn-outline-default col-sm-12">
|
||||||
|
<a href="{{qrcode.url}}" target="_blank">
|
||||||
|
<h4>{% trans 'Open in browser' %}</h4>
|
||||||
|
{{ qrcode.img|safe }}
|
||||||
|
</a>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-6 col-md-6 col-lg-6">
|
||||||
|
<button class="btn btn-outline-default col-sm-12">
|
||||||
|
<a href="{{qrcode_lanis.url}}" target="_blank">
|
||||||
|
<h4>{% trans 'View in LANIS' %}</h4>
|
||||||
|
{{ qrcode_lanis.img|safe }}
|
||||||
|
</a>
|
||||||
|
</button>
|
||||||
|
</div>
|
Loading…
Reference in New Issue
Block a user