From 67df63af0fb1c00d60ff8f27cef1a95496306bbb Mon Sep 17 00:00:00 2001 From: mpeltriaux Date: Wed, 12 Oct 2022 10:01:23 +0200 Subject: [PATCH 1/8] Quality of Life improvements * disables ordering of parcel_group ("Gemarkung") column on tables * ordering can not be done properly due to more complex nature of this column's content * introduces "Keine Geometrie vorhanden" message instead of hour glass icon on entries where no geometry has been entered yet * properly orders last_modified column by moving null values to the lower end of the ordering --- compensation/tables/compensation.py | 28 +++------------------ compensation/tables/eco_account.py | 28 +++------------------ ema/tables.py | 31 +++-------------------- intervention/tables.py | 28 +++------------------ konova/utils/tables.py | 39 +++++++++++++++++++++++++++-- templates/table/gmrkng_col.html | 18 +++++++------ 6 files changed, 60 insertions(+), 112 deletions(-) diff --git a/compensation/tables/compensation.py b/compensation/tables/compensation.py index 032ab67e..02fe00e0 100644 --- a/compensation/tables/compensation.py +++ b/compensation/tables/compensation.py @@ -14,11 +14,11 @@ from django.utils.translation import gettext_lazy as _ from compensation.filters.compensation import CompensationTableFilter from compensation.models import Compensation from konova.utils.message_templates import DATA_IS_UNCHECKED, DATA_CHECKED_ON_TEMPLATE, DATA_CHECKED_PREVIOUSLY_TEMPLATE -from konova.utils.tables import BaseTable, TableRenderMixin +from konova.utils.tables import BaseTable, TableRenderMixin, TableOrderMixin import django_tables2 as tables -class CompensationTable(BaseTable, TableRenderMixin): +class CompensationTable(BaseTable, TableRenderMixin, TableOrderMixin): id = tables.Column( verbose_name=_("Identifier"), orderable=True, @@ -31,7 +31,7 @@ class CompensationTable(BaseTable, TableRenderMixin): ) d = tables.Column( verbose_name=_("Parcel gmrkng"), - orderable=True, + orderable=False, accessor="geometry", ) c = tables.Column( @@ -126,28 +126,6 @@ class CompensationTable(BaseTable, TableRenderMixin): ) return format_html(html) - def render_d(self, value, record: Compensation): - """ Renders the parcel district column for a compensation - - Args: - value (str): The geometry - record (Compensation): The compensation record - - Returns: - - """ - parcels = value.get_underlying_parcels().values_list( - "parcel_group__name", - flat=True - ).distinct() - html = render_to_string( - "table/gmrkng_col.html", - { - "entries": parcels - } - ) - return html - def render_r(self, value, record: Compensation): """ Renders the registered column for a compensation diff --git a/compensation/tables/eco_account.py b/compensation/tables/eco_account.py index 7cd121f1..65489b5c 100644 --- a/compensation/tables/eco_account.py +++ b/compensation/tables/eco_account.py @@ -13,12 +13,12 @@ from django.utils.translation import gettext_lazy as _ from compensation.filters.eco_account import EcoAccountTableFilter from compensation.models import EcoAccount -from konova.utils.tables import TableRenderMixin, BaseTable +from konova.utils.tables import TableRenderMixin, BaseTable, TableOrderMixin import django_tables2 as tables -class EcoAccountTable(BaseTable, TableRenderMixin): +class EcoAccountTable(BaseTable, TableRenderMixin, TableOrderMixin): id = tables.Column( verbose_name=_("Identifier"), orderable=True, @@ -31,7 +31,7 @@ class EcoAccountTable(BaseTable, TableRenderMixin): ) d = tables.Column( verbose_name=_("Parcel gmrkng"), - orderable=True, + orderable=False, accessor="geometry", ) av = tables.Column( @@ -113,28 +113,6 @@ class EcoAccountTable(BaseTable, TableRenderMixin): html = render_to_string("konova/widgets/progressbar.html", {"value": value_relative}) return format_html(html) - def render_d(self, value, record): - """ Renders the parcel district column for a compensation - - Args: - value (str): The geometry - record (Compensation): The compensation record - - Returns: - - """ - parcels = value.get_underlying_parcels().values_list( - "parcel_group__name", - flat=True - ).distinct() - html = render_to_string( - "table/gmrkng_col.html", - { - "entries": parcels - } - ) - return html - def render_r(self, value, record: EcoAccount): """ Renders the recorded column for an eco account diff --git a/ema/tables.py b/ema/tables.py index d26a31dc..928b3e2b 100644 --- a/ema/tables.py +++ b/ema/tables.py @@ -6,21 +6,18 @@ Created on: 19.08.21 """ from django.http import HttpRequest -from django.template.loader import render_to_string from django.utils.html import format_html -from django.utils.timezone import localtime from django.utils.translation import gettext_lazy as _ from django.urls import reverse import django_tables2 as tables -from konova.sub_settings.django_settings import DEFAULT_DATE_TIME_FORMAT -from konova.utils.tables import BaseTable, TableRenderMixin +from konova.utils.tables import BaseTable, TableRenderMixin, TableOrderMixin from ema.filters import EmaTableFilter from ema.models import Ema -class EmaTable(BaseTable, TableRenderMixin): +class EmaTable(BaseTable, TableRenderMixin, TableOrderMixin): """ Since EMA and compensation are basically the same, we can reuse CompensationTableFilter and extend the EMA filter in the future by inheriting. @@ -37,7 +34,7 @@ class EmaTable(BaseTable, TableRenderMixin): ) d = tables.Column( verbose_name=_("Parcel gmrkng"), - orderable=True, + orderable=False, accessor="geometry", ) r = tables.Column( @@ -93,28 +90,6 @@ class EmaTable(BaseTable, TableRenderMixin): ) return format_html(html) - def render_d(self, value, record: Ema): - """ Renders the parcel district column for a ema - - Args: - value (str): The geometry - record (Ema): The ema record - - Returns: - - """ - parcels = value.get_underlying_parcels().values_list( - "parcel_group__name", - flat=True - ).distinct() - html = render_to_string( - "table/gmrkng_col.html", - { - "entries": parcels - } - ) - return html - def render_r(self, value, record: Ema): """ Renders the registered column for a EMA diff --git a/intervention/tables.py b/intervention/tables.py index cff9391c..bdcdc075 100644 --- a/intervention/tables.py +++ b/intervention/tables.py @@ -14,11 +14,11 @@ from django.utils.translation import gettext_lazy as _ from intervention.filters import InterventionTableFilter from intervention.models import Intervention from konova.utils.message_templates import DATA_CHECKED_ON_TEMPLATE, DATA_IS_UNCHECKED, DATA_CHECKED_PREVIOUSLY_TEMPLATE -from konova.utils.tables import BaseTable, TableRenderMixin +from konova.utils.tables import BaseTable, TableRenderMixin, TableOrderMixin import django_tables2 as tables -class InterventionTable(BaseTable, TableRenderMixin): +class InterventionTable(BaseTable, TableRenderMixin, TableOrderMixin): id = tables.Column( verbose_name=_("Identifier"), orderable=True, @@ -31,7 +31,7 @@ class InterventionTable(BaseTable, TableRenderMixin): ) d = tables.Column( verbose_name=_("Parcel gmrkng"), - orderable=True, + orderable=False, accessor="geometry", ) c = tables.Column( @@ -124,28 +124,6 @@ class InterventionTable(BaseTable, TableRenderMixin): ) return format_html(html) - def render_d(self, value, record: Intervention): - """ Renders the parcel district column for an intervention - - Args: - value (str): The intervention geometry - record (Intervention): The intervention record - - Returns: - - """ - parcels = value.get_underlying_parcels().values_list( - "parcel_group__name", - flat=True - ).distinct() - html = render_to_string( - "table/gmrkng_col.html", - { - "entries": parcels - } - ) - return html - def render_r(self, value, record: Intervention): """ Renders the recorded column for an intervention diff --git a/konova/utils/tables.py b/konova/utils/tables.py index d7468725..19537246 100644 --- a/konova/utils/tables.py +++ b/konova/utils/tables.py @@ -7,11 +7,13 @@ Created on: 25.11.20 """ from django.core.paginator import PageNotAnInteger, EmptyPage +from django.db.models import F from django.http import HttpRequest +from django.template.loader import render_to_string from django.utils.html import format_html import django_tables2 as tables -from konova.models import BaseObject +from konova.models import BaseObject, GeoReferencedMixin from konova.settings import PAGE_SIZE_DEFAULT, PAGE_PARAM, RESULTS_PER_PAGE_PARAM, PAGE_SIZE_OPTIONS @@ -173,4 +175,37 @@ class TableRenderMixin: max_length = 75 if len(value) > max_length: value = f"{value[:max_length]}..." - return value \ No newline at end of file + return value + + def render_d(self, value, record: GeoReferencedMixin): + """ Renders the parcel district column + + Args: + value (str): The intervention geometry + record (GeoReferencedMixin): The record + + Returns: + + """ + parcels = value.get_underlying_parcels().values_list( + "parcel_group__name", + flat=True + ).distinct() + html = render_to_string( + "table/gmrkng_col.html", + { + "entries": parcels, + "geometry": record.geometry + } + ) + return html + + +class TableOrderMixin: + """ + Holds different order_by methods for general purposes + + """ + def order_lm(self, queryset, is_asc): + queryset = queryset.order_by(F('modified__timestamp').desc(nulls_last=True)) + return (queryset, is_asc) diff --git a/templates/table/gmrkng_col.html b/templates/table/gmrkng_col.html index bd8878de..569c4c13 100644 --- a/templates/table/gmrkng_col.html +++ b/templates/table/gmrkng_col.html @@ -1,9 +1,13 @@ {% load i18n fontawesome_5 %} -{% for entry in entries %} - {{entry}} -{% empty %} - - {% fa5_icon 'hourglass-half' %} - -{% endfor %} \ No newline at end of file +{% if geometry.geom is not None %} + {% for entry in entries %} + {{entry}} + {% empty %} + + {% fa5_icon 'hourglass-half' %} + + {% endfor %} +{% else %} + {% translate 'No geometry added, yet.' %} +{% endif %} \ No newline at end of file From 7ccb3629688265ee79d34c8c79d257bcd97b8c79 Mon Sep 17 00:00:00 2001 From: mpeltriaux Date: Wed, 12 Oct 2022 10:15:27 +0200 Subject: [PATCH 2/8] New icon for missing geometry * introduces "..." as new icon for missing geometry entries * moves former explanatory message into title attribute for mouse hover activation --- templates/table/gmrkng_col.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/templates/table/gmrkng_col.html b/templates/table/gmrkng_col.html index 569c4c13..2f5521b1 100644 --- a/templates/table/gmrkng_col.html +++ b/templates/table/gmrkng_col.html @@ -9,5 +9,7 @@ {% endfor %} {% else %} - {% translate 'No geometry added, yet.' %} + + {% fa5_icon 'ellipsis-h' %} + {% endif %} \ No newline at end of file From 68e8a0201f8aa2c518c1446606966c8412d51925 Mon Sep 17 00:00:00 2001 From: mpeltriaux Date: Wed, 12 Oct 2022 10:18:57 +0200 Subject: [PATCH 3/8] Map settings button removed * removes map settings button, since there is no implementation and it is unclear, whether this will ever become a real feature --- user/templates/user/index.html | 8 -------- 1 file changed, 8 deletions(-) diff --git a/user/templates/user/index.html b/user/templates/user/index.html index cfe3bd05..9e7ac78c 100644 --- a/user/templates/user/index.html +++ b/user/templates/user/index.html @@ -38,14 +38,6 @@
-