[Intervention] Revocations files optional #4
* makes revocation file upload optional * adds overview about revocations to intervention index * adds/updates translations
This commit is contained in:
@@ -13,7 +13,7 @@ from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from intervention.filters import InterventionTableFilter
|
||||
from intervention.models import Intervention
|
||||
from konova.sub_settings.django_settings import DEFAULT_DATE_TIME_FORMAT
|
||||
from konova.sub_settings.django_settings import DEFAULT_DATE_TIME_FORMAT, DEFAULT_DATE_FORMAT
|
||||
from konova.utils.tables import BaseTable
|
||||
import django_tables2 as tables
|
||||
|
||||
@@ -41,6 +41,12 @@ class InterventionTable(BaseTable):
|
||||
empty_values=[],
|
||||
accessor="recorded",
|
||||
)
|
||||
rev = tables.Column(
|
||||
verbose_name=_("Revocation"),
|
||||
orderable=True,
|
||||
empty_values=[],
|
||||
accessor="legal__revocation",
|
||||
)
|
||||
e = tables.Column(
|
||||
verbose_name=_("Editable"),
|
||||
orderable=True,
|
||||
@@ -52,16 +58,6 @@ class InterventionTable(BaseTable):
|
||||
orderable=True,
|
||||
accessor="modified__timestamp",
|
||||
)
|
||||
"""
|
||||
# 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):
|
||||
template_name = "django_tables2/bootstrap4.html"
|
||||
@@ -164,3 +160,29 @@ class InterventionTable(BaseTable):
|
||||
icn_class="fas fa-edit rlp-r-inv" if has_access else "far fa-edit",
|
||||
)
|
||||
return format_html(html)
|
||||
|
||||
def render_rev(self, value, record: Intervention):
|
||||
""" Renders the revocation column for an intervention
|
||||
|
||||
Args:
|
||||
value (str): The revocation value
|
||||
record (Intervention): The intervention record
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
html = ""
|
||||
exists = value is not None
|
||||
tooltip = _("No revocation")
|
||||
if exists:
|
||||
_date = value.date
|
||||
added_ts = localtime(value.created.timestamp)
|
||||
added_ts = added_ts.strftime(DEFAULT_DATE_TIME_FORMAT)
|
||||
on = _date.strftime(DEFAULT_DATE_FORMAT)
|
||||
tooltip = _("Revocation from {}, added on {} by {}").format(on, added_ts, value.created.user)
|
||||
html += self.render_stop(
|
||||
tooltip=tooltip,
|
||||
icn_filled=exists,
|
||||
)
|
||||
return format_html(html)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user