2023-08-01 01:35:28 +07:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2022-03-03 15:16:23 -05:00
|
|
|
import django_tables2 as tables
|
2022-10-18 13:47:14 -07:00
|
|
|
from tenancy.models import *
|
|
|
|
from tenancy.tables import ContactsColumnMixin
|
2022-03-03 15:16:23 -05:00
|
|
|
|
|
|
|
from netbox.tables import NetBoxTable, columns
|
|
|
|
|
|
|
|
__all__ = (
|
|
|
|
'TenantGroupTable',
|
|
|
|
'TenantTable',
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class TenantGroupTable(NetBoxTable):
|
|
|
|
name = columns.MPTTColumn(
|
2023-08-01 01:35:28 +07:00
|
|
|
verbose_name=_('Name'),
|
2022-03-03 15:16:23 -05:00
|
|
|
linkify=True
|
|
|
|
)
|
|
|
|
tenant_count = columns.LinkedCountColumn(
|
|
|
|
viewname='tenancy:tenant_list',
|
|
|
|
url_params={'group_id': 'pk'},
|
2023-08-01 01:35:28 +07:00
|
|
|
verbose_name=_('Tenants')
|
2022-03-03 15:16:23 -05:00
|
|
|
)
|
|
|
|
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')
|
|
|
|
|
|
|
|
|
2022-10-18 13:47:14 -07:00
|
|
|
class TenantTable(ContactsColumnMixin, NetBoxTable):
|
2022-03-03 15:16:23 -05:00
|
|
|
name = tables.Column(
|
2023-08-01 01:35:28 +07:00
|
|
|
verbose_name=_('Name'),
|
2022-03-03 15:16:23 -05:00
|
|
|
linkify=True
|
|
|
|
)
|
|
|
|
group = tables.Column(
|
2023-08-01 01:35:28 +07:00
|
|
|
verbose_name=_('Group'),
|
2022-03-03 15:16:23 -05:00
|
|
|
linkify=True
|
|
|
|
)
|
2023-08-01 01:35:28 +07:00
|
|
|
comments = columns.MarkdownColumn(
|
|
|
|
verbose_name=_('Comments'),
|
|
|
|
)
|
2022-03-03 15:16:23 -05:00
|
|
|
tags = columns.TagColumn(
|
2023-01-17 10:32:22 -05:00
|
|
|
url_name='tenancy:tenant_list'
|
2022-03-03 15:16:23 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(NetBoxTable.Meta):
|
|
|
|
model = Tenant
|
2022-03-18 13:17:11 -04:00
|
|
|
fields = (
|
|
|
|
'pk', 'id', 'name', 'slug', 'group', 'description', 'comments', 'contacts', 'tags', 'created',
|
|
|
|
'last_updated',
|
|
|
|
)
|
2022-03-03 15:16:23 -05:00
|
|
|
default_columns = ('pk', 'name', 'group', 'description')
|