2020-10-16 10:39:13 -04:00
|
|
|
import django_tables2 as tables
|
|
|
|
|
2021-03-08 13:28:53 -05:00
|
|
|
from dcim.models import Region, Site, SiteGroup
|
2021-03-04 16:07:55 -05:00
|
|
|
from tenancy.tables import TenantColumn
|
2021-03-04 20:47:24 -05:00
|
|
|
from utilities.tables import BaseTable, ButtonsColumn, ChoiceFieldColumn, MPTTColumn, TagColumn, ToggleColumn
|
2020-10-16 10:39:13 -04:00
|
|
|
|
|
|
|
__all__ = (
|
|
|
|
'RegionTable',
|
|
|
|
'SiteTable',
|
2021-03-08 13:28:53 -05:00
|
|
|
'SiteGroupTable',
|
2020-10-16 10:39:13 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Regions
|
|
|
|
#
|
|
|
|
|
|
|
|
class RegionTable(BaseTable):
|
|
|
|
pk = ToggleColumn()
|
2021-03-26 15:07:29 -04:00
|
|
|
name = MPTTColumn(
|
|
|
|
linkify=True
|
|
|
|
)
|
2020-10-16 10:39:13 -04:00
|
|
|
site_count = tables.Column(
|
|
|
|
verbose_name='Sites'
|
|
|
|
)
|
|
|
|
actions = ButtonsColumn(Region)
|
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
model = Region
|
|
|
|
fields = ('pk', 'name', 'slug', 'site_count', 'description', 'actions')
|
|
|
|
default_columns = ('pk', 'name', 'site_count', 'description', 'actions')
|
|
|
|
|
|
|
|
|
2021-03-08 13:28:53 -05:00
|
|
|
#
|
|
|
|
# Site groups
|
|
|
|
#
|
|
|
|
|
|
|
|
class SiteGroupTable(BaseTable):
|
|
|
|
pk = ToggleColumn()
|
2021-03-26 15:07:29 -04:00
|
|
|
name = MPTTColumn(
|
|
|
|
linkify=True
|
|
|
|
)
|
2021-03-08 13:28:53 -05:00
|
|
|
site_count = tables.Column(
|
|
|
|
verbose_name='Sites'
|
|
|
|
)
|
|
|
|
actions = ButtonsColumn(SiteGroup)
|
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
model = SiteGroup
|
|
|
|
fields = ('pk', 'name', 'slug', 'site_count', 'description', 'actions')
|
|
|
|
default_columns = ('pk', 'name', 'site_count', 'description', 'actions')
|
|
|
|
|
|
|
|
|
2020-10-16 10:39:13 -04:00
|
|
|
#
|
|
|
|
# Sites
|
|
|
|
#
|
|
|
|
|
|
|
|
class SiteTable(BaseTable):
|
|
|
|
pk = ToggleColumn()
|
|
|
|
name = tables.LinkColumn(
|
|
|
|
order_by=('_name',)
|
|
|
|
)
|
|
|
|
status = ChoiceFieldColumn()
|
|
|
|
region = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2021-03-08 13:28:53 -05:00
|
|
|
group = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2021-03-04 16:07:55 -05:00
|
|
|
tenant = TenantColumn()
|
2020-10-16 10:39:13 -04:00
|
|
|
tags = TagColumn(
|
|
|
|
url_name='dcim:site_list'
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
model = Site
|
|
|
|
fields = (
|
2021-03-08 13:28:53 -05:00
|
|
|
'pk', 'name', 'slug', 'status', 'facility', 'region', 'group', 'tenant', 'asn', 'time_zone', 'description',
|
2020-10-16 10:39:13 -04:00
|
|
|
'physical_address', 'shipping_address', 'latitude', 'longitude', 'contact_name', 'contact_phone',
|
|
|
|
'contact_email', 'tags',
|
|
|
|
)
|
2021-03-08 13:28:53 -05:00
|
|
|
default_columns = ('pk', 'name', 'status', 'facility', 'region', 'group', 'tenant', 'asn', 'description')
|