HTML improvements
* refactors initializing and rendering of a map view into map/geom_form.html, which leads to simple includes on the detail views instead of redundant html * refactors django-autocomplete-light form media links and scripts into dal/scripts.html, which can be included on the header blocks of detail views to support form modals using dal easier without the need for form.media * changes filter behaviour on eco account index: instead of hiding recorded accounts (like in interventions), the filter option there has been replaced with "Show only unrecorded" which can be used to hide all recorded ones * background: eco accounts shall be visible when recorded, since they can only be used for withdrawing if they are recorded. Hiding the recorded ones does not make any sense, just like in interventions * updates some code documentation * adds/updates translations
This commit is contained in:
@@ -5,6 +5,9 @@ Contact: michel.peltriaux@sgdnord.rlp.de
|
||||
Created on: 29.07.21
|
||||
|
||||
"""
|
||||
import django_filters
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django import forms
|
||||
from django.db.models import QuerySet
|
||||
|
||||
from intervention.filters import InterventionTableFilter
|
||||
@@ -62,6 +65,12 @@ class EcoAccountTableFilter(InterventionTableFilter):
|
||||
Just some minor changes for EcoAccount model.
|
||||
|
||||
"""
|
||||
sr = django_filters.BooleanFilter(
|
||||
method='_filter_only_show_unrecorded',
|
||||
label=_("Show only unrecorded"),
|
||||
label_suffix=_(""),
|
||||
widget=forms.CheckboxInput()
|
||||
)
|
||||
|
||||
def _filter_show_all(self, queryset, name, value) -> QuerySet:
|
||||
""" Filters queryset depending on value of 'show_all' setting
|
||||
@@ -81,7 +90,7 @@ class EcoAccountTableFilter(InterventionTableFilter):
|
||||
else:
|
||||
return queryset
|
||||
|
||||
def _filter_show_recorded(self, queryset, name, value) -> QuerySet:
|
||||
def _filter_only_show_unrecorded(self, queryset, name, value) -> QuerySet:
|
||||
""" Filters queryset depending on value of 'show_recorded' setting
|
||||
|
||||
Args:
|
||||
@@ -92,7 +101,7 @@ class EcoAccountTableFilter(InterventionTableFilter):
|
||||
Returns:
|
||||
|
||||
"""
|
||||
if not value:
|
||||
if value:
|
||||
return queryset.filter(
|
||||
recorded=None,
|
||||
)
|
||||
|
||||
@@ -135,6 +135,10 @@ class NewStateModalForm(BaseModalForm):
|
||||
|
||||
Wraps the request processing logic, so we don't need the same code everywhere a RemoveModalForm is being used
|
||||
|
||||
+++
|
||||
The generic method from super class can not be used, since we need to do some request parameter check in here.
|
||||
+++
|
||||
|
||||
Args:
|
||||
request (HttpRequest): The incoming request
|
||||
msg_success (str): The message in case of successful removing
|
||||
|
||||
@@ -80,11 +80,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-12 col-md-12 col-lg-6">
|
||||
{% if geom_form.area == 0 %}
|
||||
<div class="alert alert-info">{% trans 'No geometry added, yet.' %}</div>
|
||||
{% endif %}
|
||||
{{geom_form.media}}
|
||||
{{geom_form.geom}}
|
||||
{% include 'map/geom_form.html' %}
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
|
||||
@@ -2,7 +2,13 @@
|
||||
{% load i18n l10n static fontawesome_5 humanize %}
|
||||
|
||||
{% 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 %}
|
||||
|
||||
{% block body %}
|
||||
@@ -66,11 +72,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-12 col-md-12 col-lg-6">
|
||||
{% if geom_form.area == 0 %}
|
||||
<div class="alert alert-info">{% trans 'No geometry added, yet.' %}</div>
|
||||
{% endif %}
|
||||
{{geom_form.media}}
|
||||
{{geom_form.geom}}
|
||||
{% include 'map/geom_form.html' %}
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
|
||||
Reference in New Issue
Block a user