2021-12-17 16:12:03 -05:00
|
|
|
import django_tables2 as tables
|
|
|
|
|
|
|
|
from dcim.models import Module, ModuleType
|
2022-01-27 15:48:05 -05:00
|
|
|
from netbox.tables import NetBoxTable, columns
|
2022-12-09 12:45:02 -05:00
|
|
|
from .template_code import WEIGHT
|
2021-12-17 16:12:03 -05:00
|
|
|
|
|
|
|
__all__ = (
|
|
|
|
'ModuleTable',
|
|
|
|
'ModuleTypeTable',
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class ModuleTypeTable(NetBoxTable):
|
2021-12-17 16:12:03 -05:00
|
|
|
model = tables.Column(
|
|
|
|
linkify=True,
|
|
|
|
verbose_name='Module Type'
|
|
|
|
)
|
2022-08-01 10:36:53 -04:00
|
|
|
manufacturer = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
instance_count = columns.LinkedCountColumn(
|
2021-12-17 16:12:03 -05:00
|
|
|
viewname='dcim:module_list',
|
|
|
|
url_params={'module_type_id': 'pk'},
|
|
|
|
verbose_name='Instances'
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
comments = columns.MarkdownColumn()
|
|
|
|
tags = columns.TagColumn(
|
2021-12-17 16:12:03 -05:00
|
|
|
url_name='dcim:moduletype_list'
|
|
|
|
)
|
2022-09-30 13:31:04 -07:00
|
|
|
weight = columns.TemplateColumn(
|
2022-12-09 12:45:02 -05:00
|
|
|
template_code=WEIGHT,
|
2022-09-30 13:31:04 -07:00
|
|
|
order_by=('_abs_weight', 'weight_unit')
|
|
|
|
)
|
2021-12-17 16:12:03 -05:00
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class Meta(NetBoxTable.Meta):
|
2021-12-17 16:12:03 -05:00
|
|
|
model = ModuleType
|
|
|
|
fields = (
|
2022-11-04 08:28:09 -04:00
|
|
|
'pk', 'id', 'model', 'manufacturer', 'part_number', 'weight', 'description', 'comments', 'tags',
|
2021-12-17 16:12:03 -05:00
|
|
|
)
|
|
|
|
default_columns = (
|
|
|
|
'pk', 'model', 'manufacturer', 'part_number',
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class ModuleTable(NetBoxTable):
|
2021-12-17 16:12:03 -05:00
|
|
|
device = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
|
|
|
module_bay = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2022-08-01 10:36:53 -04:00
|
|
|
manufacturer = tables.Column(
|
|
|
|
accessor=tables.A('module_type__manufacturer'),
|
|
|
|
linkify=True
|
|
|
|
)
|
2021-12-17 16:12:03 -05:00
|
|
|
module_type = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2022-12-09 10:43:29 -05:00
|
|
|
status = columns.ChoiceFieldColumn()
|
2022-01-27 15:00:10 -05:00
|
|
|
comments = columns.MarkdownColumn()
|
|
|
|
tags = columns.TagColumn(
|
2021-12-17 16:12:03 -05:00
|
|
|
url_name='dcim:module_list'
|
|
|
|
)
|
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class Meta(NetBoxTable.Meta):
|
2021-12-17 16:12:03 -05:00
|
|
|
model = Module
|
|
|
|
fields = (
|
2022-12-09 10:43:29 -05:00
|
|
|
'pk', 'id', 'device', 'module_bay', 'manufacturer', 'module_type', 'status', 'serial', 'asset_tag',
|
|
|
|
'description', 'comments', 'tags',
|
2021-12-17 16:12:03 -05:00
|
|
|
)
|
|
|
|
default_columns = (
|
2022-12-09 10:43:29 -05:00
|
|
|
'pk', 'id', 'device', 'module_bay', 'manufacturer', 'module_type', 'status', 'serial', 'asset_tag',
|
2021-12-17 16:12:03 -05:00
|
|
|
)
|