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:
@@ -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
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user