2016-03-01 11:23:03 -05:00
|
|
|
import django_tables2 as tables
|
2017-11-07 11:08:23 -05:00
|
|
|
from django_tables2.utils import Accessor
|
2017-10-20 16:27:19 -04:00
|
|
|
|
2021-03-04 16:07:55 -05:00
|
|
|
from tenancy.tables import TenantColumn
|
2021-09-17 12:04:22 -04:00
|
|
|
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',
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2021-04-05 15:24:57 -04:00
|
|
|
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
|
|
|
|
#
|
|
|
|
|
2016-06-20 16:34:19 -04:00
|
|
|
class ProviderTable(BaseTable):
|
2016-06-01 13:30:33 -04:00
|
|
|
pk = ToggleColumn()
|
2021-04-02 16:59:53 -04:00
|
|
|
name = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2020-04-28 16:20:11 -04:00
|
|
|
circuit_count = tables.Column(
|
|
|
|
accessor=Accessor('count_circuits'),
|
|
|
|
verbose_name='Circuits'
|
|
|
|
)
|
2021-09-17 12:04:22 -04:00
|
|
|
comments = MarkdownColumn()
|
2020-05-06 14:42:51 -04:00
|
|
|
tags = TagColumn(
|
|
|
|
url_name='circuits:provider_list'
|
|
|
|
)
|
2016-03-01 11:23:03 -05:00
|
|
|
|
2016-06-20 16:34:19 -04:00
|
|
|
class Meta(BaseTable.Meta):
|
2016-03-01 11:23:03 -05:00
|
|
|
model = Provider
|
2020-05-06 14:42:51 -04:00
|
|
|
fields = (
|
2021-09-17 12:04:22 -04:00
|
|
|
'pk', 'name', 'asn', 'account', 'portal_url', 'noc_contact', 'admin_contact', 'circuit_count', 'comments',
|
|
|
|
'tags',
|
2020-05-06 14:42:51 -04:00
|
|
|
)
|
2020-04-28 16:33:06 -04:00
|
|
|
default_columns = ('pk', 'name', 'asn', 'account', 'circuit_count')
|
2017-03-29 16:05:23 -04:00
|
|
|
|
|
|
|
|
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
|
|
|
|
)
|
2021-09-17 12:04:22 -04:00
|
|
|
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
|
2021-09-17 12:04:22 -04:00
|
|
|
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
|
|
|
|
#
|
|
|
|
|
2016-06-20 16:34:19 -04:00
|
|
|
class CircuitTypeTable(BaseTable):
|
2016-06-01 13:30:33 -04:00
|
|
|
pk = ToggleColumn()
|
2021-04-02 16:59:53 -04:00
|
|
|
name = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2021-10-21 10:51:02 -04:00
|
|
|
tags = TagColumn(
|
|
|
|
url_name='circuits:circuittype_list'
|
|
|
|
)
|
2020-05-06 14:42:51 -04:00
|
|
|
circuit_count = tables.Column(
|
|
|
|
verbose_name='Circuits'
|
|
|
|
)
|
2021-02-26 17:23:23 -05:00
|
|
|
actions = ButtonsColumn(CircuitType)
|
2016-05-13 12:44:03 -04:00
|
|
|
|
2016-06-20 16:34:19 -04:00
|
|
|
class Meta(BaseTable.Meta):
|
2016-05-13 12:44:03 -04:00
|
|
|
model = CircuitType
|
2021-10-21 10:51:02 -04:00
|
|
|
fields = ('pk', 'name', 'circuit_count', 'description', 'slug', 'tags', 'actions')
|
2020-04-28 16:33:06 -04:00
|
|
|
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
|
|
|
|
#
|
|
|
|
|
2016-06-20 16:34:19 -04:00
|
|
|
class CircuitTable(BaseTable):
|
2016-06-01 13:30:33 -04:00
|
|
|
pk = ToggleColumn()
|
2021-04-02 16:59:53 -04:00
|
|
|
cid = tables.Column(
|
|
|
|
linkify=True,
|
2020-05-06 14:42:51 -04:00
|
|
|
verbose_name='ID'
|
|
|
|
)
|
2021-02-26 17:23:23 -05:00
|
|
|
provider = tables.Column(
|
|
|
|
linkify=True
|
2020-05-06 14:42:51 -04:00
|
|
|
)
|
2020-09-25 10:52:14 -04:00
|
|
|
status = ChoiceFieldColumn()
|
2021-03-04 16:07:55 -05:00
|
|
|
tenant = TenantColumn()
|
2021-04-05 15:24:57 -04:00
|
|
|
termination_a = tables.TemplateColumn(
|
|
|
|
template_code=CIRCUITTERMINATION_LINK,
|
2021-03-18 13:54:05 -04:00
|
|
|
verbose_name='Side A'
|
2019-06-27 12:30:17 -04:00
|
|
|
)
|
2021-04-05 15:24:57 -04:00
|
|
|
termination_z = tables.TemplateColumn(
|
|
|
|
template_code=CIRCUITTERMINATION_LINK,
|
2021-03-18 13:54:05 -04:00
|
|
|
verbose_name='Side Z'
|
2019-06-27 12:30:17 -04:00
|
|
|
)
|
2021-09-17 12:04:22 -04:00
|
|
|
comments = MarkdownColumn()
|
2020-05-06 14:42:51 -04:00
|
|
|
tags = TagColumn(
|
|
|
|
url_name='circuits:circuit_list'
|
|
|
|
)
|
2016-03-01 11:23:03 -05:00
|
|
|
|
2016-06-20 16:34:19 -04:00
|
|
|
class Meta(BaseTable.Meta):
|
2016-03-01 11:23:03 -05:00
|
|
|
model = Circuit
|
2020-04-27 16:56:25 -04:00
|
|
|
fields = (
|
2021-03-18 13:54:05 -04:00
|
|
|
'pk', 'cid', 'provider', 'type', 'status', 'tenant', 'termination_a', 'termination_z', 'install_date',
|
2021-09-17 12:04:22 -04:00
|
|
|
'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',
|
2020-04-27 16:56:25 -04:00
|
|
|
)
|