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

104 lines
2.8 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 COL_TENANT
from utilities.tables import BaseTable, TagColumn, 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 = """
<a href="{% url 'circuits:circuittype_changelog' slug=record.slug %}" class="btn btn-default btn-xs" title="Change log">
<i class="fa fa-history"></i>
</a>
2016-05-18 15:17:58 -04:00
{% if perms.circuit.change_circuittype %}
2019-10-04 12:08:48 -04:00
<a href="{% url 'circuits:circuittype_edit' slug=record.slug %}?return_url={{ request.path }}"
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
STATUS_LABEL = """
<span class="label label-{{ record.get_status_class }}">{{ record.get_status_display }}</span>
"""
2016-03-01 11:23:03 -05:00
#
# Providers
#
class ProviderTable(BaseTable):
pk = ToggleColumn()
name = tables.LinkColumn()
circuit_count = tables.Column(
accessor=Accessor('count_circuits'),
verbose_name='Circuits'
)
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', 'tags',
)
default_columns = ('pk', 'name', 'asn', 'account', 'circuit_count')
2016-05-13 12:44:03 -04:00
#
# Circuit types
#
class CircuitTypeTable(BaseTable):
pk = ToggleColumn()
name = tables.LinkColumn()
circuit_count = tables.Column(
verbose_name='Circuits'
)
actions = tables.TemplateColumn(
template_code=CIRCUITTYPE_ACTIONS,
attrs={'td': {'class': 'text-right noprint'}},
verbose_name=''
)
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', '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.LinkColumn(
verbose_name='ID'
)
provider = tables.LinkColumn(
viewname='circuits:provider',
args=[Accessor('provider.slug')]
)
status = tables.TemplateColumn(
template_code=STATUS_LABEL
)
tenant = tables.TemplateColumn(
template_code=COL_TENANT
)
a_side = tables.Column(
verbose_name='A Side'
)
z_side = tables.Column(
verbose_name='Z Side'
)
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 = (
'pk', 'cid', 'provider', 'type', 'status', 'tenant', 'a_side', 'z_side', 'install_date', 'commit_rate',
'description', 'tags',
)
default_columns = ('pk', 'cid', 'provider', 'type', 'status', 'tenant', 'a_side', 'z_side', 'description')