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

68 lines
2.4 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 utilities.tables import BaseTable, ToggleColumn
2016-05-13 12:44:03 -04:00
from .models import Circuit, CircuitType, Provider
2016-07-28 15:04:27 -04:00
CIRCUITTYPE_ACTIONS = """
2016-05-18 15:17:58 -04:00
{% if perms.circuit.change_circuittype %}
2016-07-28 15:04:27 -04:00
<a href="{% url 'circuits:circuittype_edit' slug=record.slug %}" class="btn btn-xs btn-warning"><i class="glyphicon glyphicon-pencil" aria-hidden="true"></i></a>
2016-05-18 15:17:58 -04:00
{% endif %}
2016-05-13 12:44:03 -04:00
"""
2016-03-01 11:23:03 -05:00
#
# Providers
#
class ProviderTable(BaseTable):
pk = ToggleColumn()
2016-03-01 11:23:03 -05:00
name = tables.LinkColumn('circuits:provider', args=[Accessor('slug')], verbose_name='Name')
asn = tables.Column(verbose_name='ASN')
2016-07-29 12:33:40 -04:00
account = tables.Column(verbose_name='Account')
2016-03-01 11:23:03 -05:00
circuit_count = tables.Column(accessor=Accessor('count_circuits'), verbose_name='Circuits')
class Meta(BaseTable.Meta):
2016-03-01 11:23:03 -05:00
model = Provider
2016-07-29 12:33:40 -04:00
fields = ('pk', 'name', 'asn', 'account', 'circuit_count')
2016-03-01 11:23:03 -05:00
2016-05-13 12:44:03 -04:00
#
# Circuit types
#
class CircuitTypeTable(BaseTable):
pk = ToggleColumn()
2016-05-13 12:44:03 -04:00
name = tables.LinkColumn(verbose_name='Name')
circuit_count = tables.Column(verbose_name='Circuits')
slug = tables.Column(verbose_name='Slug')
2016-07-28 15:04:27 -04:00
actions = tables.TemplateColumn(template_code=CIRCUITTYPE_ACTIONS, attrs={'td': {'class': 'text-right'}},
verbose_name='')
2016-05-13 12:44:03 -04:00
class Meta(BaseTable.Meta):
2016-05-13 12:44:03 -04:00
model = CircuitType
2016-07-28 15:04:27 -04:00
fields = ('pk', 'name', 'circuit_count', 'slug', 'actions')
2016-05-13 12:44:03 -04:00
2016-03-01 11:23:03 -05:00
#
# Circuits
#
class CircuitTable(BaseTable):
pk = ToggleColumn()
2016-03-01 11:23:03 -05:00
cid = tables.LinkColumn('circuits:circuit', args=[Accessor('pk')], verbose_name='ID')
type = tables.Column(verbose_name='Type')
provider = tables.LinkColumn('circuits:provider', args=[Accessor('provider.slug')], verbose_name='Provider')
2016-07-26 15:42:26 -04:00
tenant = tables.LinkColumn('tenancy:tenant', args=[Accessor('tenant.slug')], verbose_name='Tenant')
a_side = tables.LinkColumn('dcim:site', accessor=Accessor('termination_a.site'), orderable=False,
args=[Accessor('termination_a.site.slug')])
z_side = tables.LinkColumn('dcim:site', accessor=Accessor('termination_z.site'), orderable=False,
args=[Accessor('termination_z.site.slug')])
description = tables.Column(verbose_name='Description')
2016-03-01 11:23:03 -05:00
class Meta(BaseTable.Meta):
2016-03-01 11:23:03 -05:00
model = Circuit
fields = ('pk', 'cid', 'type', 'provider', 'tenant', 'a_side', 'z_side', 'description')