1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

136 lines
3.3 KiB
Python
Raw Normal View History

2016-03-01 11:23:03 -05:00
import django_tables2 as tables
from django_tables2.utils import Accessor
from tenancy.tables import TenantColumn
from utilities.tables import BaseTable, ButtonsColumn, ChoiceFieldColumn, MarkdownColumn, TagColumn, ToggleColumn
2021-03-18 11:10:48 -04:00
from .models import *
2016-05-13 12:44:03 -04:00
2016-03-01 11:23:03 -05:00
2021-09-17 15:37:19 -04:00
__all__ = (
'CircuitTable',
'CircuitTypeTable',
'ProviderTable',
'ProviderNetworkTable',
)
CIRCUITTERMINATION_LINK = """
{% if value.site %}
<a href="{{ value.site.get_absolute_url }}">{{ value.site }}</a>
{% elif value.provider_network %}
<a href="{{ value.provider_network.get_absolute_url }}">{{ value.provider_network }}</a>
{% endif %}
"""
2016-03-01 11:23:03 -05:00
#
# Providers
#
class ProviderTable(BaseTable):
pk = ToggleColumn()
name = tables.Column(
linkify=True
)
circuit_count = tables.Column(
accessor=Accessor('count_circuits'),
verbose_name='Circuits'
)
comments = MarkdownColumn()
tags = TagColumn(
url_name='circuits:provider_list'
)
2016-03-01 11:23:03 -05:00
class Meta(BaseTable.Meta):
2016-03-01 11:23:03 -05:00
model = Provider
fields = (
'pk', 'name', 'asn', 'account', 'portal_url', 'noc_contact', 'admin_contact', 'circuit_count', 'comments',
'tags',
)
default_columns = ('pk', 'name', 'asn', 'account', 'circuit_count')
2021-03-18 11:10:48 -04:00
#
2021-04-01 10:21:41 -04:00
# Provider networks
2021-03-18 11:10:48 -04:00
#
2021-04-01 10:21:41 -04:00
class ProviderNetworkTable(BaseTable):
2021-03-18 11:10:48 -04:00
pk = ToggleColumn()
name = tables.Column(
linkify=True
)
provider = tables.Column(
linkify=True
)
comments = MarkdownColumn()
2021-03-18 11:10:48 -04:00
tags = TagColumn(
2021-04-01 10:21:41 -04:00
url_name='circuits:providernetwork_list'
2021-03-18 11:10:48 -04:00
)
class Meta(BaseTable.Meta):
2021-04-01 10:21:41 -04:00
model = ProviderNetwork
fields = ('pk', 'name', 'provider', 'description', 'comments', 'tags')
2021-03-18 11:10:48 -04:00
default_columns = ('pk', 'name', 'provider', 'description')
2016-05-13 12:44:03 -04:00
#
# Circuit types
#
class CircuitTypeTable(BaseTable):
pk = ToggleColumn()
name = tables.Column(
linkify=True
)
tags = TagColumn(
url_name='circuits:circuittype_list'
)
circuit_count = tables.Column(
verbose_name='Circuits'
)
actions = ButtonsColumn(CircuitType)
2016-05-13 12:44:03 -04:00
class Meta(BaseTable.Meta):
2016-05-13 12:44:03 -04:00
model = CircuitType
fields = ('pk', 'name', 'circuit_count', 'description', 'slug', 'tags', 'actions')
default_columns = ('pk', 'name', 'circuit_count', 'description', 'slug', 'actions')
2016-05-13 12:44:03 -04:00
2016-03-01 11:23:03 -05:00
#
# Circuits
#
class CircuitTable(BaseTable):
pk = ToggleColumn()
cid = tables.Column(
linkify=True,
verbose_name='ID'
)
provider = tables.Column(
linkify=True
)
status = ChoiceFieldColumn()
tenant = TenantColumn()
termination_a = tables.TemplateColumn(
template_code=CIRCUITTERMINATION_LINK,
2021-03-18 13:54:05 -04:00
verbose_name='Side A'
)
termination_z = tables.TemplateColumn(
template_code=CIRCUITTERMINATION_LINK,
2021-03-18 13:54:05 -04:00
verbose_name='Side Z'
)
comments = MarkdownColumn()
tags = TagColumn(
url_name='circuits:circuit_list'
)
2016-03-01 11:23:03 -05:00
class Meta(BaseTable.Meta):
2016-03-01 11:23:03 -05:00
model = Circuit
fields = (
2021-03-18 13:54:05 -04:00
'pk', 'cid', 'provider', 'type', 'status', 'tenant', 'termination_a', 'termination_z', 'install_date',
'commit_rate', 'description', 'comments', 'tags',
2021-03-18 13:54:05 -04:00
)
default_columns = (
'pk', 'cid', 'provider', 'type', 'status', 'tenant', 'termination_a', 'termination_z', 'description',
)