|
|
|
@ -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)
|
|
|
|
|