Database performance

* optimizes the db fetching for all index views and detail views
* introduces usage of managers.py in all necessary apps for wrapping basic fetch settings
* moves comment.html to comment_card.html under /konova/templates/konova/
* adds/updates translations
* fixes document typos
* drops comment rendering in public reports
* opens public reports in new tabs if button is clicked from the detail view
This commit is contained in:
2021-10-14 14:12:33 +02:00
parent fac6be0a8a
commit c209b2eb86
32 changed files with 364 additions and 122 deletions

View File

@@ -1,23 +0,0 @@
{% load i18n fontawesome_5 %}
{% if obj.comment %}
<div class="w-100">
<div class="card mt-3">
<div class="card-header rlp-gd">
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-12">
<h5 class="card-title">
{% fa5_icon 'info-circle' %}
{% trans 'Comment' %}
</h5>
</div>
</div>
</div>
<div class="card-body">
<div class="card-text font-italic">
{{obj.comment}}
</div>
</div>
</div>
</div>
{% endif %}

View File

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

View File

@@ -103,7 +103,7 @@
{% include 'map/geom_form.html' %}
</div>
<div class="row">
{% include 'compensation/detail/compensation/includes/comment.html' %}
{% include 'konova/comment_card.html' %}
</div>
</div>
</div>

View File

@@ -4,7 +4,7 @@
<div class="row">
<div class="col-sm-6">
<h5>
<span class="badge badge-light">{{obj.actions.count}}</span>
<span class="badge badge-light">{{actions.count}}</span>
{% trans 'Actions' context 'Compensation' %}
</h5>
</div>
@@ -33,13 +33,15 @@
<th scope="col">
{% trans 'Comment' %}
</th>
<th scope="col">
{% trans 'Action' %}
</th>
{% if default_member and has_access %}
<th scope="col">
{% trans 'Action' %}
</th>
{% endif %}
</tr>
</thead>
<tbody>
{% for action in obj.actions.all %}
{% for action in actions %}
<tr>
<td class="align-middle">
{{ action.action_type }}

View File

@@ -1,23 +0,0 @@
{% load i18n fontawesome_5 %}
{% if obj.comment %}
<div class="w-100">
<div class="card mt-3">
<div class="card-header rlp-gd">
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-12">
<h5 class="card-title">
{% fa5_icon 'info-circle' %}
{% trans 'Comment' %}
</h5>
</div>
</div>
</div>
<div class="card-body">
<div class="card-text font-italic">
{{obj.comment}}
</div>
</div>
</div>
</div>
{% endif %}

View File

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

View File

@@ -51,9 +51,9 @@
</td>
<td class="align-middle">
{% if deduction.intervention.recorded %}
<em title='{{ deduction.intervention.recorded_tooltip }}' class='fas fa-bookmark registered-bookmark'></em>
<em title="{% trans 'Recorded on' %} {{obj.recorded.timestamp}} {% trans 'by' %} {{obj.recorded.user}}" class='fas fa-bookmark registered-bookmark'></em>
{% else %}
<em title='{{ deduction.intervention.recorded_tooltip }}' class='far fa-bookmark'></em>
<em title="{% trans 'Not recorded yet' %}" class='far fa-bookmark'></em>
{% endif %}
</td>
<td class="align-middle">{{ deduction.surface|floatformat:2|intcomma }} m²</td>

View File

@@ -4,7 +4,7 @@
<div class="row">
<div class="col-sm-6">
<h5>
<span class="badge badge-light">{{obj.after_states.count}}</span>
<span class="badge badge-light">{{after_states.count}}</span>
{% trans 'States after' %}
</h5>
</div>
@@ -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>

View File

@@ -4,7 +4,7 @@
<div class="row">
<div class="col-sm-6">
<h5>
<span class="badge badge-light">{{obj.before_states.count}}</span>
<span class="badge badge-light">{{before_states.count}}</span>
{% trans 'States before' %}
</h5>
</div>
@@ -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>

View File

@@ -102,7 +102,7 @@
{% include 'map/geom_form.html' %}
</div>
<div class="row">
{% include 'compensation/detail/compensation/includes/comment.html' %}
{% include 'konova/comment_card.html' %}
</div>
</div>
</div>

View File

@@ -50,9 +50,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>

View File

@@ -0,0 +1,84 @@
{% 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 'Conservation office' %}</th>
<td class="align-middle">{{obj.responsible.conservation_office.str_as_office|default_if_none:""}}</td>
</tr>
<tr>
<th scope="row">{% trans 'Conservation office file number' %}</th>
<td class="align-middle">{{obj.responsible.conservation_file_number|default_if_none:""}}</td>
</tr>
<tr>
<th scope="row">{% trans 'Action handler' %}</th>
<td class="align-middle">{{obj.responsible.handler|default_if_none:""}}</td>
</tr>
<tr>
<th scope="row">{% trans 'Funded by' %}</th>
<td class="align-middle">
{% with obj.fundings.all as fundings %}
{% for funding in fundings %}
<div class="badge pill-badge rlp-r-outline">{{funding.short_name}}</div>
<br>
{% empty %}
{% trans 'None' %}
{% endfor %}
{% endwith %}
</td>
</tr>
<tr>
<th scope="row">{% trans 'Deductions for' %}</th>
<td class="align-middle">
{% for deduction in deductions %}
<a href="{% url 'intervention:report' deduction.intervention__id %}">
{{deduction.intervention__identifier}}
</a>
<br>
{% empty %}
{% trans 'None' %}
{% 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">
<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 %}