2020-10-16 10:39:13 -04:00
|
|
|
import django_tables2 as tables
|
|
|
|
from django_tables2.utils import Accessor
|
|
|
|
|
|
|
|
from dcim.models import Cable
|
2021-09-29 21:00:45 -04:00
|
|
|
from utilities.tables import BaseTable, ChoiceFieldColumn, ColorColumn, TagColumn, TemplateColumn, ToggleColumn
|
2020-10-16 10:39:13 -04:00
|
|
|
from .template_code import CABLE_LENGTH, CABLE_TERMINATION_PARENT
|
|
|
|
|
|
|
|
__all__ = (
|
|
|
|
'CableTable',
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Cables
|
|
|
|
#
|
|
|
|
|
|
|
|
class CableTable(BaseTable):
|
|
|
|
pk = ToggleColumn()
|
|
|
|
id = tables.Column(
|
|
|
|
linkify=True,
|
|
|
|
verbose_name='ID'
|
|
|
|
)
|
|
|
|
termination_a_parent = tables.TemplateColumn(
|
|
|
|
template_code=CABLE_TERMINATION_PARENT,
|
|
|
|
accessor=Accessor('termination_a'),
|
|
|
|
orderable=False,
|
|
|
|
verbose_name='Side A'
|
|
|
|
)
|
2021-04-02 16:59:53 -04:00
|
|
|
termination_a = tables.Column(
|
2020-10-16 10:39:13 -04:00
|
|
|
accessor=Accessor('termination_a'),
|
|
|
|
orderable=False,
|
2021-04-02 16:59:53 -04:00
|
|
|
linkify=True,
|
2020-10-16 10:39:13 -04:00
|
|
|
verbose_name='Termination A'
|
|
|
|
)
|
|
|
|
termination_b_parent = tables.TemplateColumn(
|
|
|
|
template_code=CABLE_TERMINATION_PARENT,
|
|
|
|
accessor=Accessor('termination_b'),
|
|
|
|
orderable=False,
|
|
|
|
verbose_name='Side B'
|
|
|
|
)
|
2021-04-02 16:59:53 -04:00
|
|
|
termination_b = tables.Column(
|
2020-10-16 10:39:13 -04:00
|
|
|
accessor=Accessor('termination_b'),
|
|
|
|
orderable=False,
|
2021-04-02 16:59:53 -04:00
|
|
|
linkify=True,
|
2020-10-16 10:39:13 -04:00
|
|
|
verbose_name='Termination B'
|
|
|
|
)
|
|
|
|
status = ChoiceFieldColumn()
|
2021-09-29 21:00:45 -04:00
|
|
|
length = TemplateColumn(
|
2020-10-16 10:39:13 -04:00
|
|
|
template_code=CABLE_LENGTH,
|
|
|
|
order_by='_abs_length'
|
|
|
|
)
|
|
|
|
color = ColorColumn()
|
|
|
|
tags = TagColumn(
|
|
|
|
url_name='dcim:cable_list'
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta(BaseTable.Meta):
|
|
|
|
model = Cable
|
|
|
|
fields = (
|
|
|
|
'pk', 'id', 'label', 'termination_a_parent', 'termination_a', 'termination_b_parent', 'termination_b',
|
|
|
|
'status', 'type', 'color', 'length', 'tags',
|
|
|
|
)
|
|
|
|
default_columns = (
|
|
|
|
'pk', 'id', 'label', 'termination_a_parent', 'termination_a', 'termination_b_parent', 'termination_b',
|
|
|
|
'status', 'type',
|
|
|
|
)
|