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
This commit is contained in:
parent
7235110b7d
commit
67df63af0f
@ -14,11 +14,11 @@ from django.utils.translation import gettext_lazy as _
|
|||||||
from compensation.filters.compensation import CompensationTableFilter
|
from compensation.filters.compensation import CompensationTableFilter
|
||||||
from compensation.models import Compensation
|
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.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
|
import django_tables2 as tables
|
||||||
|
|
||||||
|
|
||||||
class CompensationTable(BaseTable, TableRenderMixin):
|
class CompensationTable(BaseTable, TableRenderMixin, TableOrderMixin):
|
||||||
id = tables.Column(
|
id = tables.Column(
|
||||||
verbose_name=_("Identifier"),
|
verbose_name=_("Identifier"),
|
||||||
orderable=True,
|
orderable=True,
|
||||||
@ -31,7 +31,7 @@ class CompensationTable(BaseTable, TableRenderMixin):
|
|||||||
)
|
)
|
||||||
d = tables.Column(
|
d = tables.Column(
|
||||||
verbose_name=_("Parcel gmrkng"),
|
verbose_name=_("Parcel gmrkng"),
|
||||||
orderable=True,
|
orderable=False,
|
||||||
accessor="geometry",
|
accessor="geometry",
|
||||||
)
|
)
|
||||||
c = tables.Column(
|
c = tables.Column(
|
||||||
@ -126,28 +126,6 @@ class CompensationTable(BaseTable, TableRenderMixin):
|
|||||||
)
|
)
|
||||||
return format_html(html)
|
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):
|
def render_r(self, value, record: Compensation):
|
||||||
""" Renders the registered column for a compensation
|
""" Renders the registered column for a compensation
|
||||||
|
|
||||||
|
@ -13,12 +13,12 @@ from django.utils.translation import gettext_lazy as _
|
|||||||
|
|
||||||
from compensation.filters.eco_account import EcoAccountTableFilter
|
from compensation.filters.eco_account import EcoAccountTableFilter
|
||||||
from compensation.models import EcoAccount
|
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
|
import django_tables2 as tables
|
||||||
|
|
||||||
|
|
||||||
class EcoAccountTable(BaseTable, TableRenderMixin):
|
class EcoAccountTable(BaseTable, TableRenderMixin, TableOrderMixin):
|
||||||
id = tables.Column(
|
id = tables.Column(
|
||||||
verbose_name=_("Identifier"),
|
verbose_name=_("Identifier"),
|
||||||
orderable=True,
|
orderable=True,
|
||||||
@ -31,7 +31,7 @@ class EcoAccountTable(BaseTable, TableRenderMixin):
|
|||||||
)
|
)
|
||||||
d = tables.Column(
|
d = tables.Column(
|
||||||
verbose_name=_("Parcel gmrkng"),
|
verbose_name=_("Parcel gmrkng"),
|
||||||
orderable=True,
|
orderable=False,
|
||||||
accessor="geometry",
|
accessor="geometry",
|
||||||
)
|
)
|
||||||
av = tables.Column(
|
av = tables.Column(
|
||||||
@ -113,28 +113,6 @@ class EcoAccountTable(BaseTable, TableRenderMixin):
|
|||||||
html = render_to_string("konova/widgets/progressbar.html", {"value": value_relative})
|
html = render_to_string("konova/widgets/progressbar.html", {"value": value_relative})
|
||||||
return format_html(html)
|
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):
|
def render_r(self, value, record: EcoAccount):
|
||||||
""" Renders the recorded column for an eco account
|
""" Renders the recorded column for an eco account
|
||||||
|
|
||||||
|
@ -6,21 +6,18 @@ Created on: 19.08.21
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
from django.http import HttpRequest
|
from django.http import HttpRequest
|
||||||
from django.template.loader import render_to_string
|
|
||||||
from django.utils.html import format_html
|
from django.utils.html import format_html
|
||||||
from django.utils.timezone import localtime
|
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
import django_tables2 as tables
|
import django_tables2 as tables
|
||||||
|
|
||||||
from konova.sub_settings.django_settings import DEFAULT_DATE_TIME_FORMAT
|
from konova.utils.tables import BaseTable, TableRenderMixin, TableOrderMixin
|
||||||
from konova.utils.tables import BaseTable, TableRenderMixin
|
|
||||||
from ema.filters import EmaTableFilter
|
from ema.filters import EmaTableFilter
|
||||||
from ema.models import Ema
|
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
|
Since EMA and compensation are basically the same, we can reuse CompensationTableFilter and extend the EMA filter
|
||||||
in the future by inheriting.
|
in the future by inheriting.
|
||||||
@ -37,7 +34,7 @@ class EmaTable(BaseTable, TableRenderMixin):
|
|||||||
)
|
)
|
||||||
d = tables.Column(
|
d = tables.Column(
|
||||||
verbose_name=_("Parcel gmrkng"),
|
verbose_name=_("Parcel gmrkng"),
|
||||||
orderable=True,
|
orderable=False,
|
||||||
accessor="geometry",
|
accessor="geometry",
|
||||||
)
|
)
|
||||||
r = tables.Column(
|
r = tables.Column(
|
||||||
@ -93,28 +90,6 @@ class EmaTable(BaseTable, TableRenderMixin):
|
|||||||
)
|
)
|
||||||
return format_html(html)
|
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):
|
def render_r(self, value, record: Ema):
|
||||||
""" Renders the registered column for a EMA
|
""" Renders the registered column for a EMA
|
||||||
|
|
||||||
|
@ -14,11 +14,11 @@ from django.utils.translation import gettext_lazy as _
|
|||||||
from intervention.filters import InterventionTableFilter
|
from intervention.filters import InterventionTableFilter
|
||||||
from intervention.models import Intervention
|
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.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
|
import django_tables2 as tables
|
||||||
|
|
||||||
|
|
||||||
class InterventionTable(BaseTable, TableRenderMixin):
|
class InterventionTable(BaseTable, TableRenderMixin, TableOrderMixin):
|
||||||
id = tables.Column(
|
id = tables.Column(
|
||||||
verbose_name=_("Identifier"),
|
verbose_name=_("Identifier"),
|
||||||
orderable=True,
|
orderable=True,
|
||||||
@ -31,7 +31,7 @@ class InterventionTable(BaseTable, TableRenderMixin):
|
|||||||
)
|
)
|
||||||
d = tables.Column(
|
d = tables.Column(
|
||||||
verbose_name=_("Parcel gmrkng"),
|
verbose_name=_("Parcel gmrkng"),
|
||||||
orderable=True,
|
orderable=False,
|
||||||
accessor="geometry",
|
accessor="geometry",
|
||||||
)
|
)
|
||||||
c = tables.Column(
|
c = tables.Column(
|
||||||
@ -124,28 +124,6 @@ class InterventionTable(BaseTable, TableRenderMixin):
|
|||||||
)
|
)
|
||||||
return format_html(html)
|
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):
|
def render_r(self, value, record: Intervention):
|
||||||
""" Renders the recorded column for an intervention
|
""" Renders the recorded column for an intervention
|
||||||
|
|
||||||
|
@ -7,11 +7,13 @@ Created on: 25.11.20
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from django.core.paginator import PageNotAnInteger, EmptyPage
|
from django.core.paginator import PageNotAnInteger, EmptyPage
|
||||||
|
from django.db.models import F
|
||||||
from django.http import HttpRequest
|
from django.http import HttpRequest
|
||||||
|
from django.template.loader import render_to_string
|
||||||
from django.utils.html import format_html
|
from django.utils.html import format_html
|
||||||
import django_tables2 as tables
|
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
|
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
|
max_length = 75
|
||||||
if len(value) > max_length:
|
if len(value) > max_length:
|
||||||
value = f"{value[:max_length]}..."
|
value = f"{value[:max_length]}..."
|
||||||
return value
|
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)
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
{% load i18n fontawesome_5 %}
|
{% load i18n fontawesome_5 %}
|
||||||
|
|
||||||
{% for entry in entries %}
|
{% if geometry.geom is not None %}
|
||||||
<span class="badge pill-badge rlp-r">{{entry}}</span>
|
{% for entry in entries %}
|
||||||
{% empty %}
|
<span class="badge pill-badge rlp-r">{{entry}}</span>
|
||||||
<span class="text-info" title="{% trans 'If the geometry is not empty, the parcels are currently recalculated. Please refresh this page in a few moments.' %}">
|
{% empty %}
|
||||||
{% fa5_icon 'hourglass-half' %}
|
<span class="text-info" title="{% trans 'If the geometry is not empty, the parcels are currently recalculated. Please refresh this page in a few moments.' %}">
|
||||||
</span>
|
{% fa5_icon 'hourglass-half' %}
|
||||||
{% endfor %}
|
</span>
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
<span class="badge pill-badge rlp-r-inv">{% translate 'No geometry added, yet.' %}</span>
|
||||||
|
{% endif %}
|
Loading…
Reference in New Issue
Block a user