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

86 lines
2.5 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, SearchTable, 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()
name = tables.LinkColumn()
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
class ProviderSearchTable(SearchTable):
name = tables.LinkColumn()
class Meta(SearchTable.Meta):
model = Provider
fields = ('name', 'asn', 'account')
2016-05-13 12:44:03 -04:00
#
# Circuit types
#
class CircuitTypeTable(BaseTable):
pk = ToggleColumn()
name = tables.LinkColumn()
2016-05-13 12:44:03 -04:00
circuit_count = tables.Column(verbose_name='Circuits')
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()
cid = tables.LinkColumn(verbose_name='ID')
provider = tables.LinkColumn('circuits:provider', args=[Accessor('provider.slug')])
tenant = tables.LinkColumn('tenancy:tenant', args=[Accessor('tenant.slug')])
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')]
)
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')
class CircuitSearchTable(SearchTable):
cid = tables.LinkColumn(verbose_name='ID')
provider = tables.LinkColumn('circuits:provider', args=[Accessor('provider.slug')])
tenant = tables.LinkColumn('tenancy:tenant', args=[Accessor('tenant.slug')])
class Meta(SearchTable.Meta):
model = Circuit
fields = ('cid', 'type', 'provider', 'tenant', 'description')