#86 Parcel district column for all
* adds parcel district column for all major data objects * adds warning about intervention-revocation on index view of compensations * adds warning about intervention-revocation on detail view of related compensations
This commit is contained in:
@@ -21,7 +21,7 @@ from konova.contexts import BaseContext
|
||||
from konova.forms import BaseModalForm, NewDocumentForm, RemoveModalForm
|
||||
from konova.models import DeadlineType
|
||||
from konova.utils.message_templates import FORM_INVALID, ADDED_COMPENSATION_STATE, ADDED_DEADLINE, \
|
||||
ADDED_COMPENSATION_ACTION, PAYMENT_ADDED
|
||||
ADDED_COMPENSATION_ACTION
|
||||
|
||||
|
||||
class NewPaymentForm(BaseModalForm):
|
||||
|
||||
@@ -22,7 +22,7 @@ from konova.models import BaseObject, AbstractDocument, Deadline, generate_docum
|
||||
from konova.settings import DEFAULT_SRID_RLP, LANIS_LINK_TEMPLATE
|
||||
from konova.utils.message_templates import DATA_UNSHARED_EXPLANATION, COMPENSATION_REMOVED_TEMPLATE, \
|
||||
DOCUMENT_REMOVED_TEMPLATE, COMPENSATION_EDITED_TEMPLATE, DEADLINE_REMOVED, ADDED_DEADLINE, \
|
||||
COMPENSATION_ACTION_REMOVED, COMPENSATION_STATE_REMOVED
|
||||
COMPENSATION_ACTION_REMOVED, COMPENSATION_STATE_REMOVED, INTERVENTION_HAS_REVOCATIONS_TEMPLATE
|
||||
from user.models import UserActionLogEntry
|
||||
|
||||
|
||||
@@ -390,6 +390,26 @@ class Compensation(AbstractCompensation, CEFMixin, CoherenceMixin):
|
||||
"""
|
||||
return self.intervention.is_ready_for_publish()
|
||||
|
||||
def set_status_messages(self, request: HttpRequest):
|
||||
""" Setter for different information that need to be rendered
|
||||
|
||||
Adds messages to the given HttpRequest
|
||||
|
||||
Args:
|
||||
request (HttpRequest): The incoming request
|
||||
|
||||
Returns:
|
||||
request (HttpRequest): The modified request
|
||||
"""
|
||||
if self.intervention.legal.revocations.exists():
|
||||
messages.error(
|
||||
request,
|
||||
INTERVENTION_HAS_REVOCATIONS_TEMPLATE.format(self.intervention.legal.revocations.count()),
|
||||
extra_tags="danger",
|
||||
)
|
||||
super().set_status_messages(request)
|
||||
return request
|
||||
|
||||
|
||||
class CompensationDocument(AbstractDocument):
|
||||
"""
|
||||
|
||||
@@ -31,6 +31,11 @@ class CompensationTable(BaseTable, TableRenderMixin):
|
||||
orderable=True,
|
||||
accessor="title",
|
||||
)
|
||||
d = tables.Column(
|
||||
verbose_name=_("Parcel gmrkng"),
|
||||
orderable=True,
|
||||
accessor="geometry",
|
||||
)
|
||||
c = tables.Column(
|
||||
verbose_name=_("Checked"),
|
||||
orderable=True,
|
||||
@@ -80,14 +85,17 @@ class CompensationTable(BaseTable, TableRenderMixin):
|
||||
Returns:
|
||||
|
||||
"""
|
||||
html = ""
|
||||
html += self.render_link(
|
||||
tooltip=_("Open {}").format(_("Compensation")),
|
||||
href=reverse("compensation:detail", args=(record.id,)),
|
||||
txt=value,
|
||||
new_tab=False,
|
||||
context = {
|
||||
"tooltip": _("Open {}").format(_("Intervention")),
|
||||
"content": value,
|
||||
"url": reverse("compensation:detail", args=(record.id,)),
|
||||
"has_revocations": record.intervention.legal.revocations.exists()
|
||||
}
|
||||
html = render_to_string(
|
||||
"table/revocation_warning_col.html",
|
||||
context
|
||||
)
|
||||
return format_html(html)
|
||||
return html
|
||||
|
||||
def render_c(self, value, record: Compensation):
|
||||
""" Renders the checked column for a compensation
|
||||
@@ -115,6 +123,28 @@ 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.parcels.values_list(
|
||||
"gmrkng",
|
||||
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
|
||||
|
||||
@@ -173,10 +203,20 @@ class EcoAccountTable(BaseTable, TableRenderMixin):
|
||||
orderable=True,
|
||||
accessor="title",
|
||||
)
|
||||
d = tables.Column(
|
||||
verbose_name=_("Parcel gmrkng"),
|
||||
orderable=True,
|
||||
accessor="geometry",
|
||||
)
|
||||
av = tables.Column(
|
||||
verbose_name=_("Available"),
|
||||
orderable=True,
|
||||
empty_values=[],
|
||||
attrs={
|
||||
"th": {
|
||||
"class": "w-20",
|
||||
}
|
||||
}
|
||||
)
|
||||
r = tables.Column(
|
||||
verbose_name=_("Recorded"),
|
||||
@@ -244,6 +284,28 @@ 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: Compensation):
|
||||
""" Renders the parcel district column for a compensation
|
||||
|
||||
Args:
|
||||
value (str): The geometry
|
||||
record (Compensation): The compensation record
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
parcels = value.parcels.values_list(
|
||||
"gmrkng",
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user