Tweak table columns

This commit is contained in:
Jeremy Stretch 2024-07-17 10:03:12 -04:00
parent 7594ecc790
commit fcbb8c9112

View File

@ -1,8 +1,7 @@
from datetime import datetime
import django_tables2 as tables import django_tables2 as tables
from django.contrib.humanize.templatetags.humanize import naturalday
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from netbox.tables import BaseTable
from netbox.tables import BaseTable, columns
__all__ = ( __all__ = (
'CatalogPluginTable', 'CatalogPluginTable',
@ -14,8 +13,9 @@ class PluginVersionTable(BaseTable):
version = tables.Column( version = tables.Column(
verbose_name=_('Version') verbose_name=_('Version')
) )
last_updated = tables.Column( last_updated = columns.DateTimeColumn(
accessor=tables.A('date'), accessor=tables.A('date'),
timespec='minutes',
verbose_name=_('Last Updated') verbose_name=_('Last Updated')
) )
min_version = tables.Column( min_version = tables.Column(
@ -37,9 +37,6 @@ class PluginVersionTable(BaseTable):
) )
orderable = False orderable = False
def render_last_updated(self, value, record):
return naturalday(value)
class CatalogPluginTable(BaseTable): class CatalogPluginTable(BaseTable):
name = tables.Column( name = tables.Column(
@ -49,19 +46,19 @@ class CatalogPluginTable(BaseTable):
author = tables.Column( author = tables.Column(
verbose_name=_('Author') verbose_name=_('Author')
) )
is_local = tables.BooleanColumn( is_local = columns.BooleanColumn(
verbose_name=_('Local') verbose_name=_('Local')
) )
is_installed = tables.BooleanColumn( is_installed = columns.BooleanColumn(
verbose_name=_('Installed') verbose_name=_('Installed')
) )
is_certified = tables.BooleanColumn( is_certified = columns.BooleanColumn(
verbose_name=_('Certified') verbose_name=_('Certified')
) )
created = tables.Column( created = columns.DateTimeColumn(
verbose_name=_('Published') verbose_name=_('Published')
) )
updated = tables.Column( updated = columns.DateTimeColumn(
verbose_name=_('Updated') verbose_name=_('Updated')
) )