2016-03-01 11:23:03 -05:00
|
|
|
import django_tables2 as tables
|
2023-03-29 07:27:11 -05:00
|
|
|
|
2022-03-03 15:16:23 -05:00
|
|
|
from circuits.models import *
|
2022-10-18 13:47:14 -07:00
|
|
|
from tenancy.tables import ContactsColumnMixin, TenancyColumnsMixin
|
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
from netbox.tables import NetBoxTable, columns
|
2022-10-18 13:47:14 -07:00
|
|
|
|
2022-03-03 15:16:23 -05:00
|
|
|
from .columns import CommitRateColumn
|
2016-05-13 12:44:03 -04:00
|
|
|
|
2021-09-17 15:37:19 -04:00
|
|
|
__all__ = (
|
|
|
|
'CircuitTable',
|
|
|
|
'CircuitTypeTable',
|
|
|
|
)
|
|
|
|
|
|
|
|
|
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 %}
|
|
|
|
"""
|
|
|
|
|
2022-01-27 15:00:10 -05:00
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class CircuitTypeTable(NetBoxTable):
|
2021-04-02 16:59:53 -04:00
|
|
|
name = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
tags = columns.TagColumn(
|
2021-10-21 10:51:02 -04:00
|
|
|
url_name='circuits:circuittype_list'
|
|
|
|
)
|
2023-01-25 16:20:52 -05:00
|
|
|
circuit_count = columns.LinkedCountColumn(
|
|
|
|
viewname='circuits:circuit_list',
|
|
|
|
url_params={'type_id': 'pk'},
|
2020-05-06 14:42:51 -04:00
|
|
|
verbose_name='Circuits'
|
|
|
|
)
|
2016-05-13 12:44:03 -04:00
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class Meta(NetBoxTable.Meta):
|
2016-05-13 12:44:03 -04:00
|
|
|
model = CircuitType
|
2022-01-17 11:12:54 -05:00
|
|
|
fields = (
|
|
|
|
'pk', 'id', 'name', 'circuit_count', 'description', 'slug', 'tags', 'created', 'last_updated', 'actions',
|
|
|
|
)
|
2022-01-07 10:36:58 -05:00
|
|
|
default_columns = ('pk', 'name', 'circuit_count', 'description', 'slug')
|
2016-05-13 12:44:03 -04:00
|
|
|
|
|
|
|
|
2022-10-18 13:47:14 -07:00
|
|
|
class CircuitTable(TenancyColumnsMixin, ContactsColumnMixin, NetBoxTable):
|
2021-04-02 16:59:53 -04:00
|
|
|
cid = tables.Column(
|
|
|
|
linkify=True,
|
2021-11-02 16:24:28 -04:00
|
|
|
verbose_name='Circuit ID'
|
2020-05-06 14:42:51 -04:00
|
|
|
)
|
2021-02-26 17:23:23 -05:00
|
|
|
provider = tables.Column(
|
|
|
|
linkify=True
|
2020-05-06 14:42:51 -04:00
|
|
|
)
|
2023-03-29 07:27:11 -05:00
|
|
|
provider_account = tables.Column(
|
|
|
|
linkify=True,
|
|
|
|
verbose_name='Account'
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
status = columns.ChoiceFieldColumn()
|
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
|
|
|
)
|
2023-04-10 16:35:21 -04:00
|
|
|
commit_rate = CommitRateColumn(
|
|
|
|
verbose_name='Commit Rate'
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
comments = columns.MarkdownColumn()
|
|
|
|
tags = columns.TagColumn(
|
2020-05-06 14:42:51 -04:00
|
|
|
url_name='circuits:circuit_list'
|
|
|
|
)
|
2016-03-01 11:23:03 -05:00
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class Meta(NetBoxTable.Meta):
|
2016-03-01 11:23:03 -05:00
|
|
|
model = Circuit
|
2020-04-27 16:56:25 -04:00
|
|
|
fields = (
|
2023-03-29 07:27:11 -05:00
|
|
|
'pk', 'id', 'cid', 'provider', 'provider_account', 'type', 'status', 'tenant', 'tenant_group',
|
|
|
|
'termination_a', 'termination_z', 'install_date', 'termination_date', 'commit_rate', 'description',
|
|
|
|
'comments', 'contacts', 'tags', 'created', 'last_updated',
|
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
|
|
|
)
|