114 lines
3.2 KiB
Python
114 lines
3.2 KiB
Python
|
"""
|
||
|
Author: Michel Peltriaux
|
||
|
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
|
||
|
Contact: michel.peltriaux@sgdnord.rlp.de
|
||
|
Created on: 01.12.20
|
||
|
|
||
|
"""
|
||
|
from django.urls import reverse
|
||
|
from django.utils.html import format_html
|
||
|
from django.utils.translation import gettext_lazy as _
|
||
|
|
||
|
from konova.utils.tables import BaseTable
|
||
|
import django_tables2 as tables
|
||
|
|
||
|
|
||
|
class CompensationTable(BaseTable):
|
||
|
id = tables.Column(
|
||
|
verbose_name=_("Identifier"),
|
||
|
orderable=True,
|
||
|
accessor="identifier",
|
||
|
)
|
||
|
t = tables.Column(
|
||
|
verbose_name=_("Title"),
|
||
|
orderable=True,
|
||
|
accessor="title",
|
||
|
)
|
||
|
d = tables.Column(
|
||
|
verbose_name=_("Created on"),
|
||
|
orderable=True,
|
||
|
accessor="created_on",
|
||
|
)
|
||
|
ac = tables.Column(
|
||
|
verbose_name=_("Actions"),
|
||
|
orderable=False,
|
||
|
empty_values=[],
|
||
|
attrs={"td": {"class": "action-col"}}
|
||
|
)
|
||
|
|
||
|
def __init__(self, *args, **kwargs):
|
||
|
super().__init__(*args, **kwargs)
|
||
|
self.title = _("Compensations")
|
||
|
self.add_new_url = reverse("compensation:new")
|
||
|
|
||
|
def render_ac(self, value, record):
|
||
|
"""
|
||
|
Renders possible actions for this record, such as delete.
|
||
|
"""
|
||
|
intervention = _("Compensation")
|
||
|
html = ""
|
||
|
html += self.render_open_btn(
|
||
|
_("Open {}").format(intervention),
|
||
|
reverse("compensation:open", args=(record.id,)),
|
||
|
new_tab=True
|
||
|
)
|
||
|
html += self.render_edit_btn(
|
||
|
_("Edit {}").format(intervention),
|
||
|
reverse("compensation:edit", args=(record.id,)),
|
||
|
)
|
||
|
html += self.render_delete_btn(
|
||
|
_("Delete {}").format(intervention),
|
||
|
reverse("compensation:remove", args=(record.id,)),
|
||
|
)
|
||
|
return format_html(html)
|
||
|
|
||
|
|
||
|
class EcoAccountTable(BaseTable):
|
||
|
id = tables.Column(
|
||
|
verbose_name=_("Identifier"),
|
||
|
orderable=True,
|
||
|
accessor="identifier",
|
||
|
)
|
||
|
t = tables.Column(
|
||
|
verbose_name=_("Title"),
|
||
|
orderable=True,
|
||
|
accessor="title",
|
||
|
)
|
||
|
d = tables.Column(
|
||
|
verbose_name=_("Created on"),
|
||
|
orderable=True,
|
||
|
accessor="created_on",
|
||
|
)
|
||
|
ac = tables.Column(
|
||
|
verbose_name=_("Actions"),
|
||
|
orderable=False,
|
||
|
empty_values=[],
|
||
|
attrs={"td": {"class": "action-col"}}
|
||
|
)
|
||
|
|
||
|
def __init__(self, *args, **kwargs):
|
||
|
super().__init__(*args, **kwargs)
|
||
|
self.title = _("Eco Accounts")
|
||
|
self.add_new_url = reverse("compensation:account-new")
|
||
|
|
||
|
def render_ac(self, value, record):
|
||
|
"""
|
||
|
Renders possible actions for this record, such as delete.
|
||
|
"""
|
||
|
intervention = _("Compensation")
|
||
|
html = ""
|
||
|
html += self.render_open_btn(
|
||
|
_("Open {}").format(intervention),
|
||
|
reverse("compensation:open", args=(record.id,)),
|
||
|
new_tab=True
|
||
|
)
|
||
|
html += self.render_edit_btn(
|
||
|
_("Edit {}").format(intervention),
|
||
|
reverse("compensation:edit", args=(record.id,)),
|
||
|
)
|
||
|
html += self.render_delete_btn(
|
||
|
_("Delete {}").format(intervention),
|
||
|
reverse("compensation:remove", args=(record.id,)),
|
||
|
)
|
||
|
return format_html(html)
|