#25 Public reports
* adds public report for compensations * adds/updates translations * prepares EMA and eco account reports
This commit is contained in:
@@ -15,6 +15,7 @@ urlpatterns = [
|
||||
path('<id>', detail_view, name='acc-detail'),
|
||||
path('<id>/log', log_view, name='acc-log'),
|
||||
path('<id>/record', record_view, name='acc-record'),
|
||||
path('<id>/report', report_view, name='acc-report'),
|
||||
path('<id>/edit', edit_view, name='acc-edit'),
|
||||
path('<id>/remove', remove_view, name='acc-remove'),
|
||||
path('<id>/state/new', state_new_view, name='acc-new-state'),
|
||||
|
||||
@@ -21,6 +21,7 @@ urlpatterns = [
|
||||
path('<id>/state/new', state_new_view, name='new-state'),
|
||||
path('<id>/action/new', action_new_view, name='new-action'),
|
||||
path('<id>/deadline/new', deadline_new_view, name="new-deadline"),
|
||||
path('<id>/report', report_view, name='report'),
|
||||
|
||||
# Documents
|
||||
path('<id>/document/new/', new_document_view, name='new-doc'),
|
||||
|
||||
@@ -33,9 +33,11 @@
|
||||
<th scope="col">
|
||||
{% trans 'Comment' %}
|
||||
</th>
|
||||
{% if is_default_member and has_access %}
|
||||
<th scope="col">
|
||||
{% trans 'Action' %}
|
||||
</th>
|
||||
{% endif %}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
LANIS
|
||||
</button>
|
||||
</a>
|
||||
<a href="{% url 'home' %}" class="mr-2">
|
||||
<a href="{% url 'compensation:report' obj.id %}" class="mr-2">
|
||||
<button class="btn btn-default" title="{% trans 'Public report' %}">
|
||||
{% fa5_icon 'file-alt' %}
|
||||
</button>
|
||||
|
||||
@@ -35,9 +35,11 @@
|
||||
<th scope="col">
|
||||
{% trans 'Surface' %}
|
||||
</th>
|
||||
{% if is_default_member and has_access %}
|
||||
<th scope="col">
|
||||
{% trans 'Action' %}
|
||||
</th>
|
||||
{% endif %}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
@@ -35,9 +35,11 @@
|
||||
<th scope="col">
|
||||
{% trans 'Surface' %}
|
||||
</th>
|
||||
{% if is_default_member and has_access %}
|
||||
<th scope="col">
|
||||
{% trans 'Action' %}
|
||||
</th>
|
||||
{% endif %}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
LANIS
|
||||
</button>
|
||||
</a>
|
||||
<a href="{% url 'home' %}" class="mr-2">
|
||||
<a href="{% url 'compensation:acc-report' obj.id %}" class="mr-2">
|
||||
<button class="btn btn-default" title="{% trans 'Public report' %}">
|
||||
{% fa5_icon 'file-alt' %}
|
||||
</button>
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
{% extends 'public_base.html' %}
|
||||
{% load i18n fontawesome_5 humanize %}
|
||||
|
||||
{% block body %}
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-md-12 col-lg-6">
|
||||
<h3>{% trans 'Report' %}</h3>
|
||||
<h4>{{obj.identifier}}</h4>
|
||||
<div class="table-container">
|
||||
<table class="table table-hover">
|
||||
<tr>
|
||||
<th class="w-25" scope="row">{% trans 'Title' %}</th>
|
||||
<td class="align-middle">{{obj.title|default_if_none:""}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'compensates intervention' %}</th>
|
||||
<td class="align-middle">
|
||||
<a href="{% url 'intervention:report' obj.intervention.id %}">
|
||||
{{obj.intervention.identifier}}
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Funded by' %}</th>
|
||||
<td class="align-middle">
|
||||
{% for funding in obj.fundings.all %}
|
||||
<div class="badge pill-badge rlp-r-outline">{{funding.short_name}}</div>
|
||||
<br>
|
||||
{% endfor %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Last modified' %}</th>
|
||||
<td class="align-middle">
|
||||
{{obj.modified.timestamp|default_if_none:""|naturalday}}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{% include 'compensation/detail/compensation/includes/states-before.html' %}
|
||||
{% include 'compensation/detail/compensation/includes/states-after.html' %}
|
||||
{% include 'compensation/detail/compensation/includes/actions.html' %}
|
||||
</div>
|
||||
<div class="col-sm-12 col-md-12 col-lg-6">
|
||||
<div class="row">
|
||||
{% include 'map/geom_form.html' %}
|
||||
</div>
|
||||
<div class="row">
|
||||
{% include 'intervention/detail/includes/comment.html' %}
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-6 col-md-6 col-lg-6">
|
||||
<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>
|
||||
|
||||
{% endblock %}
|
||||
@@ -13,6 +13,7 @@ from konova.contexts import BaseContext
|
||||
from konova.decorators import *
|
||||
from konova.forms import RemoveModalForm, SimpleGeomForm, NewDocumentForm
|
||||
from konova.utils.documents import get_document, remove_document
|
||||
from konova.utils.generators import generate_qr_code
|
||||
from konova.utils.message_templates import FORM_INVALID, IDENTIFIER_REPLACED
|
||||
from konova.utils.user_checks import in_group
|
||||
|
||||
@@ -381,3 +382,50 @@ def action_remove_view(request: HttpRequest, id: str):
|
||||
request,
|
||||
msg_success=_("Action removed")
|
||||
)
|
||||
|
||||
|
||||
def report_view(request:HttpRequest, id: str):
|
||||
""" Renders the public report view
|
||||
|
||||
Args:
|
||||
request (HttpRequest): The incoming request
|
||||
id (str): The id of the intervention
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
# Reuse the compensation report template since compensations are structurally identical
|
||||
template = "compensation/report/compensation/report.html"
|
||||
comp = get_object_or_404(Compensation, id=id)
|
||||
|
||||
# If intervention is not recorded (yet or currently) we need to render another template without any data
|
||||
if not comp.intervention.recorded:
|
||||
template = "report/unavailable.html"
|
||||
return render(request, template, {})
|
||||
|
||||
# Prepare data for map viewer
|
||||
geom_form = SimpleGeomForm(
|
||||
instance=comp
|
||||
)
|
||||
qrcode_img = generate_qr_code(
|
||||
request.build_absolute_uri(reverse("compensation:report", args=(id,))),
|
||||
10
|
||||
)
|
||||
qrcode_img_lanis = generate_qr_code(
|
||||
comp.get_LANIS_link(),
|
||||
7
|
||||
)
|
||||
# Order states by surface
|
||||
before_states = comp.before_states.all().order_by("-surface")
|
||||
after_states = comp.after_states.all().order_by("-surface")
|
||||
context = {
|
||||
"obj": comp,
|
||||
"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,
|
||||
}
|
||||
context = BaseContext(request, context).context
|
||||
return render(request, template, context)
|
||||
|
||||
@@ -24,6 +24,7 @@ from konova.decorators import any_group_check, default_group_required, conservat
|
||||
from konova.forms import RemoveModalForm, SimpleGeomForm, NewDocumentForm, RecordModalForm
|
||||
from konova.settings import DEFAULT_GROUP, ZB_GROUP, ETS_GROUP
|
||||
from konova.utils.documents import get_document, remove_document
|
||||
from konova.utils.generators import generate_qr_code
|
||||
from konova.utils.message_templates import IDENTIFIER_REPLACED, FORM_INVALID
|
||||
from konova.utils.user_checks import in_group
|
||||
|
||||
@@ -432,3 +433,39 @@ def new_deduction_view(request: HttpRequest, id: str):
|
||||
request,
|
||||
msg_success=_("Deduction added")
|
||||
)
|
||||
|
||||
|
||||
def report_view(request:HttpRequest, id: str):
|
||||
""" Renders the public report view
|
||||
|
||||
Args:
|
||||
request (HttpRequest): The incoming request
|
||||
id (str): The id of the intervention
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
# Reuse the compensation report template since EcoAccounts are structurally identical
|
||||
template = "compensation/report/report.html"
|
||||
acc = get_object_or_404(EcoAccount, id=id)
|
||||
|
||||
# If intervention is not recorded (yet or currently) we need to render another template without any data
|
||||
if not acc.recorded:
|
||||
template = "report/unavailable.html"
|
||||
return render(request, template, {})
|
||||
|
||||
qrcode_img = generate_qr_code(
|
||||
request.build_absolute_uri(reverse("compensation:acc-report", args=(id,))),
|
||||
10
|
||||
)
|
||||
qrcode_img_lanis = generate_qr_code(
|
||||
acc.get_LANIS_link(),
|
||||
7
|
||||
)
|
||||
context = {
|
||||
"obj": acc,
|
||||
"qrcode": qrcode_img,
|
||||
"qrcode_lanis": qrcode_img_lanis,
|
||||
}
|
||||
context = BaseContext(request, context).context
|
||||
return render(request, template, context)
|
||||
|
||||
Reference in New Issue
Block a user