1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00
Arthur Hanson e284cd7e54 Closes #13150: Wrap table column headers with gettext()
Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2023-07-31 14:35:28 -04:00

59 lines
1.6 KiB
Python

from django.utils.translation import gettext_lazy as _
import django_tables2 as tables
from tenancy.models import *
from tenancy.tables import ContactsColumnMixin
from netbox.tables import NetBoxTable, columns
__all__ = (
'TenantGroupTable',
'TenantTable',
)
class TenantGroupTable(NetBoxTable):
name = columns.MPTTColumn(
verbose_name=_('Name'),
linkify=True
)
tenant_count = columns.LinkedCountColumn(
viewname='tenancy:tenant_list',
url_params={'group_id': 'pk'},
verbose_name=_('Tenants')
)
tags = columns.TagColumn(
url_name='tenancy:tenantgroup_list'
)
class Meta(NetBoxTable.Meta):
model = TenantGroup
fields = (
'pk', 'id', 'name', 'tenant_count', 'description', 'slug', 'tags', 'created', 'last_updated', 'actions',
)
default_columns = ('pk', 'name', 'tenant_count', 'description')
class TenantTable(ContactsColumnMixin, NetBoxTable):
name = tables.Column(
verbose_name=_('Name'),
linkify=True
)
group = tables.Column(
verbose_name=_('Group'),
linkify=True
)
comments = columns.MarkdownColumn(
verbose_name=_('Comments'),
)
tags = columns.TagColumn(
url_name='tenancy:tenant_list'
)
class Meta(NetBoxTable.Meta):
model = Tenant
fields = (
'pk', 'id', 'name', 'slug', 'group', 'description', 'comments', 'contacts', 'tags', 'created',
'last_updated',
)
default_columns = ('pk', 'name', 'group', 'description')