#49 Parcels on report

* adds parcel displaying on public reports
* fixes bug in EMA where autocomplete js would not load for modal forms
* fixes bug where BaseContext cached data from last request and reused it, if not overwritten
This commit is contained in:
mpeltriaux 2022-01-05 14:41:32 +01:00
parent 49859d17d2
commit a09fdae58c
10 changed files with 36 additions and 11 deletions

View File

@ -37,6 +37,9 @@
<div class="row"> <div class="row">
{% include 'map/geom_form.html' %} {% include 'map/geom_form.html' %}
</div> </div>
<div class="row">
{% include 'konova/includes/parcels.html' %}
</div>
<div class="row"> <div class="row">
<div class="col-sm-6 col-md-6 col-lg-6"> <div class="col-sm-6 col-md-6 col-lg-6">
<h4>{% trans 'Open in browser' %}</h4> <h4>{% trans 'Open in browser' %}</h4>

View File

@ -54,6 +54,9 @@
<div class="row"> <div class="row">
{% include 'map/geom_form.html' %} {% include 'map/geom_form.html' %}
</div> </div>
<div class="row">
{% include 'konova/includes/parcels.html' %}
</div>
<div class="row"> <div class="row">
<div class="col-sm-6 col-md-6 col-lg-6"> <div class="col-sm-6 col-md-6 col-lg-6">
<h4>{% trans 'Open in browser' %}</h4> <h4>{% trans 'Open in browser' %}</h4>

View File

@ -453,6 +453,7 @@ def report_view(request: HttpRequest, id: str):
geom_form = SimpleGeomForm( geom_form = SimpleGeomForm(
instance=comp instance=comp
) )
parcels = comp.get_underlying_parcels()
qrcode_img = generate_qr_code( qrcode_img = generate_qr_code(
request.build_absolute_uri(reverse("compensation:report", args=(id,))), request.build_absolute_uri(reverse("compensation:report", args=(id,))),
10 10
@ -474,6 +475,7 @@ def report_view(request: HttpRequest, id: str):
"before_states": before_states, "before_states": before_states,
"after_states": after_states, "after_states": after_states,
"geom_form": geom_form, "geom_form": geom_form,
"parcels": parcels,
"actions": actions, "actions": actions,
} }
context = BaseContext(request, context).context context = BaseContext(request, context).context

View File

@ -555,6 +555,7 @@ def report_view(request:HttpRequest, id: str):
geom_form = SimpleGeomForm( geom_form = SimpleGeomForm(
instance=acc instance=acc
) )
parcels = acc.get_underlying_parcels()
qrcode_img = generate_qr_code( qrcode_img = generate_qr_code(
request.build_absolute_uri(reverse("ema:report", args=(id,))), request.build_absolute_uri(reverse("ema:report", args=(id,))),
10 10
@ -582,6 +583,7 @@ def report_view(request:HttpRequest, id: str):
"before_states": before_states, "before_states": before_states,
"after_states": after_states, "after_states": after_states,
"geom_form": geom_form, "geom_form": geom_form,
"parcels": parcels,
"actions": actions, "actions": actions,
"deductions": deductions, "deductions": deductions,
} }

View File

@ -2,7 +2,13 @@
{% load i18n l10n static fontawesome_5 humanize %} {% load i18n l10n static fontawesome_5 humanize %}
{% block head %} {% block head %}
{% comment %}
dal documentation (django-autocomplete-light) states using form.media for adding needed scripts.
This does not work properly with modal forms, as the scripts are not loaded properly inside the modal.
Therefore the script linkages from form.media have been extracted and put inside dal/scripts.html to ensure
these scripts are loaded when needed.
{% endcomment %}
{% include 'dal/scripts.html' %}
{% endblock %} {% endblock %}
{% block body %} {% block body %}

View File

@ -41,6 +41,9 @@
<div class="row"> <div class="row">
{% include 'map/geom_form.html' %} {% include 'map/geom_form.html' %}
</div> </div>
<div class="row">
{% include 'konova/includes/parcels.html' %}
</div>
<div class="row"> <div class="row">
<div class="col-sm-6 col-md-6 col-lg-6"> <div class="col-sm-6 col-md-6 col-lg-6">
<h4>{% trans 'Open in browser' %}</h4> <h4>{% trans 'Open in browser' %}</h4>

View File

@ -466,6 +466,7 @@ def report_view(request:HttpRequest, id: str):
geom_form = SimpleGeomForm( geom_form = SimpleGeomForm(
instance=ema, instance=ema,
) )
parcels = ema.get_underlying_parcels()
qrcode_img = generate_qr_code( qrcode_img = generate_qr_code(
request.build_absolute_uri(reverse("ema:report", args=(id,))), request.build_absolute_uri(reverse("ema:report", args=(id,))),
10 10
@ -487,6 +488,7 @@ def report_view(request:HttpRequest, id: str):
"before_states": before_states, "before_states": before_states,
"after_states": after_states, "after_states": after_states,
"geom_form": geom_form, "geom_form": geom_form,
"parcels": parcels,
"actions": actions, "actions": actions,
} }
context = BaseContext(request, context).context context = BaseContext(request, context).context

View File

@ -100,6 +100,9 @@
<div class="row"> <div class="row">
{% include 'map/geom_form.html' %} {% include 'map/geom_form.html' %}
</div> </div>
<div class="row">
{% include 'konova/includes/parcels.html' %}
</div>
<div class="row"> <div class="row">
<div class="col-sm-6 col-md-6 col-lg-6"> <div class="col-sm-6 col-md-6 col-lg-6">
<h4>{% trans 'Open in browser' %}</h4> <h4>{% trans 'Open in browser' %}</h4>

View File

@ -547,6 +547,7 @@ def report_view(request:HttpRequest, id: str):
geom_form = SimpleGeomForm( geom_form = SimpleGeomForm(
instance=intervention instance=intervention
) )
parcels = intervention.get_underlying_parcels()
distinct_deductions = intervention.deductions.all().distinct( distinct_deductions = intervention.deductions.all().distinct(
"account" "account"
@ -565,6 +566,7 @@ def report_view(request:HttpRequest, id: str):
"qrcode": qrcode_img, "qrcode": qrcode_img,
"qrcode_lanis": qrcode_img_lanis, "qrcode_lanis": qrcode_img_lanis,
"geom_form": geom_form, "geom_form": geom_form,
"parcels": parcels,
} }
context = BaseContext(request, context).context context = BaseContext(request, context).context
return render(request, template, context) return render(request, template, context)

View File

@ -15,18 +15,17 @@ class BaseContext:
""" """
Holds all base data which is needed for every context rendering Holds all base data which is needed for every context rendering
""" """
context = { context = None
"base_title": BASE_TITLE,
"base_frontend_title": BASE_FRONTEND_TITLE,
"language": LANGUAGE_CODE,
"user": None,
"current_role": None,
"help_link": HELP_LINK,
}
def __init__(self, request: HttpRequest, additional_context: dict = {}): def __init__(self, request: HttpRequest, additional_context: dict = {}):
self.context["language"] = request.LANGUAGE_CODE self.context = {
self.context["user"] = request.user "base_title": BASE_TITLE,
"base_frontend_title": BASE_FRONTEND_TITLE,
"language": request.LANGUAGE_CODE,
"user": request.user,
"current_role": None,
"help_link": HELP_LINK
}
# Add additional context, derived from given parameters # Add additional context, derived from given parameters
self.context.update(additional_context) self.context.update(additional_context)