diff --git a/compensation/tables/compensation.py b/compensation/tables/compensation.py index 032ab67e..fe3efe00 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 @@ -170,20 +148,3 @@ class CompensationTable(BaseTable, TableRenderMixin): ) return format_html(html) - def render_e(self, value, record: Compensation): - """ Renders the editable column for a compensation - - Args: - value (str): The identifier value - record (Compensation): The compensation record - - Returns: - - """ - has_access = record.is_shared_with(self.user) - - html = self.render_icn( - tooltip=_("Full access granted") if has_access else _("Access not granted"), - icn_class="fas fa-edit rlp-r-inv" if has_access else "far fa-edit", - ) - return format_html(html) diff --git a/compensation/tables/eco_account.py b/compensation/tables/eco_account.py index 7cd121f1..da1444ea 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 @@ -156,23 +134,3 @@ class EcoAccountTable(BaseTable, TableRenderMixin): icn_filled=checked, ) return format_html(html) - - def render_e(self, value, record: EcoAccount): - """ Renders the editable column for an eco account - - Args: - value (str): The identifier value - record (EcoAccount): The eco account record - - Returns: - - """ - html = "" - # Do not use value in here, since value does use unprefetched 'users' manager, where record has already - # prefetched users data - has_access = record.is_shared_with(self.user) - html += self.render_icn( - tooltip=_("Full access granted") if has_access else _("Access not granted"), - icn_class="fas fa-edit rlp-r-inv" if has_access else "far fa-edit", - ) - return format_html(html) diff --git a/ema/tables.py b/ema/tables.py index d26a31dc..aa043c2c 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 @@ -136,22 +111,3 @@ class EmaTable(BaseTable, TableRenderMixin): icn_filled=recorded, ) return format_html(html) - - def render_e(self, value, record: Ema): - """ Renders the editable column for a EMA - - Args: - value (str): The identifier value - record (Ema): The EMA record - - Returns: - - """ - html = "" - has_access = record.is_shared_with(self.user) - - html += self.render_icn( - tooltip=_("Full access granted") if has_access else _("Access not granted"), - icn_class="fas fa-edit rlp-r-inv" if has_access else "far fa-edit", - ) - return format_html(html) diff --git a/ema/views/ema.py b/ema/views/ema.py index b298959f..b4ad6fd0 100644 --- a/ema/views/ema.py +++ b/ema/views/ema.py @@ -39,9 +39,8 @@ def index_view(request: HttpRequest): template = "generic_index.html" emas = Ema.objects.filter( deleted=None, - ).order_by( - "-modified" ) + table = EmaTable( request, queryset=emas diff --git a/intervention/tables.py b/intervention/tables.py index cff9391c..39cae2a9 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 @@ -168,22 +146,3 @@ class InterventionTable(BaseTable, TableRenderMixin): ) return format_html(html) - def render_e(self, value, record: Intervention): - """ Renders the editable column for an intervention - - Args: - value (str): The identifier value - record (Intervention): The intervention record - - Returns: - - """ - html = "" - has_access = record.is_shared_with(self.user) - - html += self.render_icn( - tooltip=_("Full access granted") if has_access else _("Access not granted"), - icn_class="fas fa-edit rlp-r-inv" if has_access else "far fa-edit", - ) - return format_html(html) - diff --git a/konova/models/geometry.py b/konova/models/geometry.py index f69fcc7e..f8c272f9 100644 --- a/konova/models/geometry.py +++ b/konova/models/geometry.py @@ -213,12 +213,9 @@ class Geometry(BaseResource): geojson (dict): The FeatureCollection json (as dict) """ geom = self.geom - geom.transform(ct=srid) + if geom.srid != srid: + geom.transform(ct=srid) - polygons = [] - for coords in geom.coords: - p = Polygon(coords[0], srid=geom.srid) - polygons.append(p) geojson = { "type": "FeatureCollection", "crs": { @@ -230,8 +227,8 @@ class Geometry(BaseResource): "features": [ { "type": "Feature", - "geometry": json.loads(x.geojson) - } for x in polygons + "geometry": json.loads(geom.json), + } ] } return geojson diff --git a/konova/sub_settings/context_settings.py b/konova/sub_settings/context_settings.py index d4b1821c..4d34a8f9 100644 --- a/konova/sub_settings/context_settings.py +++ b/konova/sub_settings/context_settings.py @@ -10,5 +10,5 @@ BASE_TITLE_SHORT = "KSP" BASE_TITLE = "KSP - Kompensationsverzeichnis Service Portal" BASE_FRONTEND_TITLE = "Kompensationsverzeichnis Service Portal" TAB_TITLE_IDENTIFIER = "tab_title" -HELP_LINK = "https://dienste.naturschutz.rlp.de/doku/doku.php?id=ksp:start" +HELP_LINK = "https://dienste.naturschutz.rlp.de/doku/doku.php?id=ksp2:start" IMPRESSUM_LINK = "https://naturschutz.rlp.de/index.php?q=impressum" diff --git a/konova/templates/konova/includes/parcels/parcel_table_frame.html b/konova/templates/konova/includes/parcels/parcel_table_frame.html index 21b75b76..8adc2e80 100644 --- a/konova/templates/konova/includes/parcels/parcel_table_frame.html +++ b/konova/templates/konova/includes/parcels/parcel_table_frame.html @@ -1,7 +1,8 @@ -{% load i18n l10n %} +{% load i18n l10n fontawesome_5 %}