6ac0556601
* adds basic bootstrap classes to BaseTable model
100 lines
2.7 KiB
Python
100 lines
2.7 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 intervention.models import Intervention
|
|
from konova.utils.tables import BaseTable
|
|
import django_tables2 as tables
|
|
|
|
|
|
class InterventionTable(BaseTable):
|
|
id = tables.Column(
|
|
verbose_name=_("Identifier"),
|
|
orderable=True,
|
|
accessor="identifier",
|
|
)
|
|
t = tables.Column(
|
|
verbose_name=_("Title"),
|
|
orderable=True,
|
|
accessor="title",
|
|
)
|
|
c = tables.Column(
|
|
verbose_name=_("Checked"),
|
|
orderable=True,
|
|
accessor="recorded_on",
|
|
)
|
|
r = tables.Column(
|
|
verbose_name=_("Registered"),
|
|
orderable=True,
|
|
accessor="recorded_on",
|
|
)
|
|
lm = tables.Column(
|
|
verbose_name=_("Last edit"),
|
|
orderable=True,
|
|
accessor="created_on",
|
|
)
|
|
"""
|
|
# ToDo: Decide to keep actions column or to dismiss them
|
|
|
|
ac = tables.Column(
|
|
verbose_name=_("Actions"),
|
|
orderable=False,
|
|
empty_values=[],
|
|
attrs={"td": {"class": "action-col"}}
|
|
)
|
|
"""
|
|
|
|
class Meta(BaseTable.Meta):
|
|
pass
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
self.title = _("Interventions")
|
|
self.add_new_url = reverse("intervention:new")
|
|
|
|
def render_id(self, value, record: Intervention):
|
|
""" Renders the id column for an intervention
|
|
|
|
Args:
|
|
value (str): The identifier value
|
|
record (Intervention): The intervention record
|
|
|
|
Returns:
|
|
|
|
"""
|
|
html = ""
|
|
html += self.render_link(
|
|
tooltip=_("Open {}").format(_("Intervention")),
|
|
href=reverse("intervention:open", args=(record.id,)),
|
|
txt=value,
|
|
new_tab=False,
|
|
)
|
|
return format_html(html)
|
|
|
|
def render_ac(self, value, record):
|
|
"""
|
|
Renders possible actions for this record, such as delete.
|
|
"""
|
|
intervention = _("Intervention")
|
|
html = ""
|
|
html += self.render_open_btn(
|
|
_("Open {}").format(intervention),
|
|
reverse("intervention:open", args=(record.id,))
|
|
)
|
|
html += self.render_edit_btn(
|
|
_("Edit {}").format(intervention),
|
|
reverse("intervention:edit", args=(record.id,)),
|
|
)
|
|
html += self.render_delete_btn(
|
|
_("Delete {}").format(intervention),
|
|
reverse("intervention:remove", args=(record.id,)),
|
|
)
|
|
return format_html(html)
|