#25 Public reports

* adds public report for compensations
* adds/updates translations
* prepares EMA and eco account reports
This commit is contained in:
2021-10-13 17:35:11 +02:00
parent 7daceb947f
commit 354ec4c929
17 changed files with 303 additions and 88 deletions

View File

@@ -6,7 +6,7 @@
LANIS
</button>
</a>
<a href="{% url 'home' %}" class="mr-2">
<a href="{% url 'ema:report' obj.id %}" class="mr-2">
<button class="btn btn-default" title="{% trans 'Public report' %}">
{% fa5_icon 'file-alt' %}
</button>

View File

@@ -18,6 +18,7 @@ urlpatterns = [
path('<id>/edit', edit_view, name='edit'),
path('<id>/remove', remove_view, name='remove'),
path('<id>/record', record_view, name='record'),
path('<id>/report', report_view, name='report'),
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"),

View File

@@ -16,6 +16,7 @@ from ema.models import Ema, EmaDocument
from konova.forms import RemoveModalForm, NewDocumentForm, SimpleGeomForm, 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
@@ -399,3 +400,38 @@ def action_remove_view(request: HttpRequest, id: str):
id
)
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 EMAs are structurally identical
template = "compensation/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
if not ema.recorded:
template = "report/unavailable.html"
return render(request, template, {})
qrcode_img = generate_qr_code(
request.build_absolute_uri(reverse("ema:report", args=(id,))),
10
)
qrcode_img_lanis = generate_qr_code(
ema.get_LANIS_link(),
7
)
context = {
"obj": ema,
"qrcode": qrcode_img,
"qrcode_lanis": qrcode_img_lanis,
}
context = BaseContext(request, context).context
return render(request, template, context)