mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-18 21:16:27 -06:00
Update and simplify device component tables
This commit is contained in:
parent
3badfd756c
commit
2001cfe864
@ -490,18 +490,6 @@ class ConsolePortTemplateTable(ComponentTemplateTable):
|
||||
empty_text = "None"
|
||||
|
||||
|
||||
class ConsolePortImportTable(BaseTable):
|
||||
device = tables.LinkColumn(
|
||||
viewname='dcim:device',
|
||||
args=[Accessor('device.pk')]
|
||||
)
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
model = ConsolePort
|
||||
fields = ('device', 'name', 'description')
|
||||
empty_text = False
|
||||
|
||||
|
||||
class ConsoleServerPortTemplateTable(ComponentTemplateTable):
|
||||
actions = tables.TemplateColumn(
|
||||
template_code=get_component_template_actions('consoleserverporttemplate'),
|
||||
@ -515,18 +503,6 @@ class ConsoleServerPortTemplateTable(ComponentTemplateTable):
|
||||
empty_text = "None"
|
||||
|
||||
|
||||
class ConsoleServerPortImportTable(BaseTable):
|
||||
device = tables.LinkColumn(
|
||||
viewname='dcim:device',
|
||||
args=[Accessor('device.pk')]
|
||||
)
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
model = ConsoleServerPort
|
||||
fields = ('device', 'name', 'description')
|
||||
empty_text = False
|
||||
|
||||
|
||||
class PowerPortTemplateTable(ComponentTemplateTable):
|
||||
actions = tables.TemplateColumn(
|
||||
template_code=get_component_template_actions('powerporttemplate'),
|
||||
@ -540,18 +516,6 @@ class PowerPortTemplateTable(ComponentTemplateTable):
|
||||
empty_text = "None"
|
||||
|
||||
|
||||
class PowerPortImportTable(BaseTable):
|
||||
device = tables.LinkColumn(
|
||||
viewname='dcim:device',
|
||||
args=[Accessor('device.pk')]
|
||||
)
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
model = PowerPort
|
||||
fields = ('device', 'name', 'description', 'maximum_draw', 'allocated_draw')
|
||||
empty_text = False
|
||||
|
||||
|
||||
class PowerOutletTemplateTable(ComponentTemplateTable):
|
||||
actions = tables.TemplateColumn(
|
||||
template_code=get_component_template_actions('poweroutlettemplate'),
|
||||
@ -565,18 +529,6 @@ class PowerOutletTemplateTable(ComponentTemplateTable):
|
||||
empty_text = "None"
|
||||
|
||||
|
||||
class PowerOutletImportTable(BaseTable):
|
||||
device = tables.LinkColumn(
|
||||
viewname='dcim:device',
|
||||
args=[Accessor('device.pk')]
|
||||
)
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
model = PowerOutlet
|
||||
fields = ('device', 'name', 'description', 'power_port', 'feed_leg')
|
||||
empty_text = False
|
||||
|
||||
|
||||
class InterfaceTemplateTable(ComponentTemplateTable):
|
||||
mgmt_only = BooleanColumn(
|
||||
verbose_name='Management Only'
|
||||
@ -593,20 +545,6 @@ class InterfaceTemplateTable(ComponentTemplateTable):
|
||||
empty_text = "None"
|
||||
|
||||
|
||||
class InterfaceImportTable(BaseTable):
|
||||
device = tables.LinkColumn(
|
||||
viewname='dcim:device',
|
||||
args=[Accessor('device.pk')]
|
||||
)
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
model = Interface
|
||||
fields = (
|
||||
'device', 'name', 'description', 'lag', 'type', 'enabled', 'mac_address', 'mtu', 'mgmt_only', 'mode',
|
||||
)
|
||||
empty_text = False
|
||||
|
||||
|
||||
class FrontPortTemplateTable(ComponentTemplateTable):
|
||||
rear_port_position = tables.Column(
|
||||
verbose_name='Position'
|
||||
@ -623,18 +561,6 @@ class FrontPortTemplateTable(ComponentTemplateTable):
|
||||
empty_text = "None"
|
||||
|
||||
|
||||
class FrontPortImportTable(BaseTable):
|
||||
device = tables.LinkColumn(
|
||||
viewname='dcim:device',
|
||||
args=[Accessor('device.pk')]
|
||||
)
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
model = FrontPort
|
||||
fields = ('device', 'name', 'description', 'type', 'rear_port', 'rear_port_position')
|
||||
empty_text = False
|
||||
|
||||
|
||||
class RearPortTemplateTable(ComponentTemplateTable):
|
||||
actions = tables.TemplateColumn(
|
||||
template_code=get_component_template_actions('rearporttemplate'),
|
||||
@ -648,18 +574,6 @@ class RearPortTemplateTable(ComponentTemplateTable):
|
||||
empty_text = "None"
|
||||
|
||||
|
||||
class RearPortImportTable(BaseTable):
|
||||
device = tables.LinkColumn(
|
||||
viewname='dcim:device',
|
||||
args=[Accessor('device.pk')]
|
||||
)
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
model = RearPort
|
||||
fields = ('device', 'name', 'description', 'type', 'position')
|
||||
empty_text = False
|
||||
|
||||
|
||||
class DeviceBayTemplateTable(ComponentTemplateTable):
|
||||
actions = tables.TemplateColumn(
|
||||
template_code=get_component_template_actions('devicebaytemplate'),
|
||||
@ -855,144 +769,94 @@ class DeviceImportTable(BaseTable):
|
||||
# Device components
|
||||
#
|
||||
|
||||
class DeviceComponentDetailTable(BaseTable):
|
||||
class DeviceComponentTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
device = tables.LinkColumn()
|
||||
name = tables.Column(order_by=('_name',))
|
||||
cable = tables.LinkColumn()
|
||||
device = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
name = tables.Column(
|
||||
linkify=True,
|
||||
order_by=('_name',)
|
||||
)
|
||||
cable = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
order_by = ('device', 'name')
|
||||
fields = ('pk', 'device', 'name', 'label', 'type', 'description', 'cable')
|
||||
sequence = ('pk', 'device', 'name', 'label', 'type', 'description', 'cable')
|
||||
|
||||
|
||||
class ConsolePortTable(BaseTable):
|
||||
name = tables.Column(order_by=('_name',))
|
||||
class ConsolePortTable(DeviceComponentTable):
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
class Meta(DeviceComponentTable.Meta):
|
||||
model = ConsolePort
|
||||
fields = ('name', 'label', 'type')
|
||||
fields = ('pk', 'device', 'name', 'label', 'type', 'description', 'cable')
|
||||
default_columns = ('pk', 'device', 'name', 'label', 'type', 'description')
|
||||
|
||||
|
||||
class ConsolePortDetailTable(DeviceComponentDetailTable):
|
||||
class ConsoleServerPortTable(DeviceComponentTable):
|
||||
|
||||
class Meta(DeviceComponentDetailTable.Meta, ConsolePortTable.Meta):
|
||||
pass
|
||||
|
||||
|
||||
class ConsoleServerPortTable(BaseTable):
|
||||
name = tables.Column(order_by=('_name',))
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
class Meta(DeviceComponentTable.Meta):
|
||||
model = ConsoleServerPort
|
||||
fields = ('name', 'label', 'description')
|
||||
fields = ('pk', 'device', 'name', 'label', 'type', 'description', 'cable')
|
||||
default_columns = ('pk', 'device', 'name', 'label', 'type', 'description')
|
||||
|
||||
|
||||
class ConsoleServerPortDetailTable(DeviceComponentDetailTable):
|
||||
class PowerPortTable(DeviceComponentTable):
|
||||
|
||||
class Meta(DeviceComponentDetailTable.Meta, ConsoleServerPortTable.Meta):
|
||||
pass
|
||||
|
||||
|
||||
class PowerPortTable(BaseTable):
|
||||
name = tables.Column(order_by=('_name',))
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
class Meta(DeviceComponentTable.Meta):
|
||||
model = PowerPort
|
||||
fields = ('name', 'label', 'type')
|
||||
fields = ('pk', 'device', 'name', 'label', 'type', 'description', 'maximum_draw', 'allocated_draw', 'cable')
|
||||
default_columns = ('pk', 'device', 'name', 'label', 'type', 'maximum_draw', 'allocated_draw', 'description')
|
||||
|
||||
|
||||
class PowerPortDetailTable(DeviceComponentDetailTable):
|
||||
class PowerOutletTable(DeviceComponentTable):
|
||||
|
||||
class Meta(DeviceComponentDetailTable.Meta, PowerPortTable.Meta):
|
||||
pass
|
||||
|
||||
|
||||
class PowerOutletTable(BaseTable):
|
||||
name = tables.Column(order_by=('_name',))
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
class Meta(DeviceComponentTable.Meta):
|
||||
model = PowerOutlet
|
||||
fields = ('name', 'label', 'type', 'description')
|
||||
fields = ('pk', 'device', 'name', 'label', 'type', 'description', 'power_port', 'feed_leg', 'cable')
|
||||
default_columns = ('pk', 'device', 'name', 'label', 'type', 'power_port', 'feed_leg', 'description')
|
||||
|
||||
|
||||
class PowerOutletDetailTable(DeviceComponentDetailTable):
|
||||
|
||||
class Meta(DeviceComponentDetailTable.Meta, PowerOutletTable.Meta):
|
||||
pass
|
||||
|
||||
|
||||
class InterfaceTable(BaseTable):
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
model = Interface
|
||||
fields = ('name', 'label', 'type', 'lag', 'enabled', 'mgmt_only', 'description')
|
||||
|
||||
|
||||
class InterfaceDetailTable(DeviceComponentDetailTable):
|
||||
class InterfaceTable(DeviceComponentTable):
|
||||
enabled = BooleanColumn()
|
||||
|
||||
class Meta(DeviceComponentDetailTable.Meta, InterfaceTable.Meta):
|
||||
fields = ('pk', 'device', 'name', 'label', 'enabled', 'type', 'description', 'cable')
|
||||
sequence = ('pk', 'device', 'name', 'label', 'enabled', 'type', 'description', 'cable')
|
||||
class Meta(DeviceComponentTable.Meta):
|
||||
model = Interface
|
||||
fields = (
|
||||
'pk', 'device', 'name', 'label', 'enabled', 'type', 'mgmt_only', 'mtu', 'mode', 'description', 'cable',
|
||||
)
|
||||
default_columns = ('pk', 'device', 'name', 'label', 'enabled', 'type', 'description')
|
||||
|
||||
|
||||
class FrontPortTable(BaseTable):
|
||||
name = tables.Column(order_by=('_name',))
|
||||
class FrontPortTable(DeviceComponentTable):
|
||||
rear_port_position = tables.Column(
|
||||
verbose_name='Position'
|
||||
)
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
class Meta(DeviceComponentTable.Meta):
|
||||
model = FrontPort
|
||||
fields = ('name', 'label', 'type', 'rear_port', 'rear_port_position', 'description')
|
||||
empty_text = "None"
|
||||
fields = ('pk', 'device', 'name', 'label', 'type', 'rear_port', 'rear_port_position', 'description', 'cable')
|
||||
default_columns = ('pk', 'device', 'name', 'label', 'type', 'rear_port', 'rear_port_position', 'description')
|
||||
|
||||
|
||||
class FrontPortDetailTable(DeviceComponentDetailTable):
|
||||
class RearPortTable(DeviceComponentTable):
|
||||
|
||||
class Meta(DeviceComponentDetailTable.Meta, FrontPortTable.Meta):
|
||||
pass
|
||||
|
||||
|
||||
class RearPortTable(BaseTable):
|
||||
name = tables.Column(order_by=('_name',))
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
class Meta(DeviceComponentTable.Meta):
|
||||
model = RearPort
|
||||
fields = ('name', 'label', 'type', 'positions', 'description')
|
||||
empty_text = "None"
|
||||
fields = ('pk', 'device', 'name', 'label', 'type', 'positions', 'description', 'cable')
|
||||
default_columns = ('pk', 'device', 'name', 'label', 'type', 'description')
|
||||
|
||||
|
||||
class RearPortDetailTable(DeviceComponentDetailTable):
|
||||
class DeviceBayTable(DeviceComponentTable):
|
||||
installed_device = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
|
||||
class Meta(DeviceComponentDetailTable.Meta, RearPortTable.Meta):
|
||||
pass
|
||||
|
||||
|
||||
class DeviceBayTable(BaseTable):
|
||||
name = tables.Column(order_by=('_name',))
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
class Meta(DeviceComponentTable.Meta):
|
||||
model = DeviceBay
|
||||
fields = ('name', 'label', 'description')
|
||||
|
||||
|
||||
class DeviceBayDetailTable(DeviceComponentDetailTable):
|
||||
installed_device = tables.LinkColumn()
|
||||
|
||||
class Meta(DeviceBayTable.Meta):
|
||||
fields = ('pk', 'device', 'name', 'label', 'installed_device', 'description')
|
||||
sequence = ('pk', 'device', 'name', 'label', 'installed_device', 'description')
|
||||
exclude = ('cable',)
|
||||
|
||||
|
||||
class DeviceBayImportTable(BaseTable):
|
||||
device = tables.LinkColumn('dcim:device', args=[Accessor('device.pk')], verbose_name='Device')
|
||||
installed_device = tables.LinkColumn('dcim:device', args=[Accessor('installed_device.pk')], verbose_name='Installed Device')
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
model = DeviceBay
|
||||
fields = ('device', 'name', 'installed_device', 'description')
|
||||
empty_text = False
|
||||
default_columns = ('pk', 'device', 'name', 'label', 'installed_device', 'description')
|
||||
|
||||
|
||||
#
|
||||
|
@ -1158,10 +1158,10 @@ class DeviceBulkDeleteView(BulkDeleteView):
|
||||
#
|
||||
|
||||
class ConsolePortListView(ObjectListView):
|
||||
queryset = ConsolePort.objects.prefetch_related('device', 'device__tenant', 'device__site', 'cable')
|
||||
queryset = ConsolePort.objects.prefetch_related('device', 'cable')
|
||||
filterset = filters.ConsolePortFilterSet
|
||||
filterset_form = forms.ConsolePortFilterForm
|
||||
table = tables.ConsolePortDetailTable
|
||||
table = tables.ConsolePortTable
|
||||
action_buttons = ('import', 'export')
|
||||
|
||||
|
||||
@ -1188,7 +1188,7 @@ class ConsolePortDeleteView(ObjectDeleteView):
|
||||
class ConsolePortBulkImportView(BulkImportView):
|
||||
queryset = ConsolePort.objects.all()
|
||||
model_form = forms.ConsolePortCSVForm
|
||||
table = tables.ConsolePortImportTable
|
||||
table = tables.ConsolePortTable
|
||||
default_return_url = 'dcim:consoleport_list'
|
||||
|
||||
|
||||
@ -1211,10 +1211,10 @@ class ConsolePortBulkDeleteView(BulkDeleteView):
|
||||
#
|
||||
|
||||
class ConsoleServerPortListView(ObjectListView):
|
||||
queryset = ConsoleServerPort.objects.prefetch_related('device', 'device__tenant', 'device__site', 'cable')
|
||||
queryset = ConsoleServerPort.objects.prefetch_related('device', 'cable')
|
||||
filterset = filters.ConsoleServerPortFilterSet
|
||||
filterset_form = forms.ConsoleServerPortFilterForm
|
||||
table = tables.ConsoleServerPortDetailTable
|
||||
table = tables.ConsoleServerPortTable
|
||||
action_buttons = ('import', 'export')
|
||||
|
||||
|
||||
@ -1241,7 +1241,7 @@ class ConsoleServerPortDeleteView(ObjectDeleteView):
|
||||
class ConsoleServerPortBulkImportView(BulkImportView):
|
||||
queryset = ConsoleServerPort.objects.all()
|
||||
model_form = forms.ConsoleServerPortCSVForm
|
||||
table = tables.ConsoleServerPortImportTable
|
||||
table = tables.ConsoleServerPortTable
|
||||
default_return_url = 'dcim:consoleserverport_list'
|
||||
|
||||
|
||||
@ -1274,10 +1274,10 @@ class ConsoleServerPortBulkDeleteView(BulkDeleteView):
|
||||
#
|
||||
|
||||
class PowerPortListView(ObjectListView):
|
||||
queryset = PowerPort.objects.prefetch_related('device', 'device__tenant', 'device__site', 'cable')
|
||||
queryset = PowerPort.objects.prefetch_related('device', 'cable')
|
||||
filterset = filters.PowerPortFilterSet
|
||||
filterset_form = forms.PowerPortFilterForm
|
||||
table = tables.PowerPortDetailTable
|
||||
table = tables.PowerPortTable
|
||||
action_buttons = ('import', 'export')
|
||||
|
||||
|
||||
@ -1304,7 +1304,7 @@ class PowerPortDeleteView(ObjectDeleteView):
|
||||
class PowerPortBulkImportView(BulkImportView):
|
||||
queryset = PowerPort.objects.all()
|
||||
model_form = forms.PowerPortCSVForm
|
||||
table = tables.PowerPortImportTable
|
||||
table = tables.PowerPortTable
|
||||
default_return_url = 'dcim:powerport_list'
|
||||
|
||||
|
||||
@ -1327,10 +1327,10 @@ class PowerPortBulkDeleteView(BulkDeleteView):
|
||||
#
|
||||
|
||||
class PowerOutletListView(ObjectListView):
|
||||
queryset = PowerOutlet.objects.prefetch_related('device', 'device__tenant', 'device__site', 'cable')
|
||||
queryset = PowerOutlet.objects.prefetch_related('device', 'cable')
|
||||
filterset = filters.PowerOutletFilterSet
|
||||
filterset_form = forms.PowerOutletFilterForm
|
||||
table = tables.PowerOutletDetailTable
|
||||
table = tables.PowerOutletTable
|
||||
action_buttons = ('import', 'export')
|
||||
|
||||
|
||||
@ -1357,7 +1357,7 @@ class PowerOutletDeleteView(ObjectDeleteView):
|
||||
class PowerOutletBulkImportView(BulkImportView):
|
||||
queryset = PowerOutlet.objects.all()
|
||||
model_form = forms.PowerOutletCSVForm
|
||||
table = tables.PowerOutletImportTable
|
||||
table = tables.PowerOutletTable
|
||||
default_return_url = 'dcim:poweroutlet_list'
|
||||
|
||||
|
||||
@ -1390,10 +1390,10 @@ class PowerOutletBulkDeleteView(BulkDeleteView):
|
||||
#
|
||||
|
||||
class InterfaceListView(ObjectListView):
|
||||
queryset = Interface.objects.prefetch_related('device', 'device__tenant', 'device__site', 'cable')
|
||||
queryset = Interface.objects.prefetch_related('device', 'cable')
|
||||
filterset = filters.InterfaceFilterSet
|
||||
filterset_form = forms.InterfaceFilterForm
|
||||
table = tables.InterfaceDetailTable
|
||||
table = tables.InterfaceTable
|
||||
action_buttons = ('import', 'export')
|
||||
|
||||
|
||||
@ -1453,7 +1453,7 @@ class InterfaceDeleteView(ObjectDeleteView):
|
||||
class InterfaceBulkImportView(BulkImportView):
|
||||
queryset = Interface.objects.all()
|
||||
model_form = forms.InterfaceCSVForm
|
||||
table = tables.InterfaceImportTable
|
||||
table = tables.InterfaceTable
|
||||
default_return_url = 'dcim:interface_list'
|
||||
|
||||
|
||||
@ -1486,10 +1486,10 @@ class InterfaceBulkDeleteView(BulkDeleteView):
|
||||
#
|
||||
|
||||
class FrontPortListView(ObjectListView):
|
||||
queryset = FrontPort.objects.prefetch_related('device', 'device__tenant', 'device__site', 'cable')
|
||||
queryset = FrontPort.objects.prefetch_related('device', 'cable')
|
||||
filterset = filters.FrontPortFilterSet
|
||||
filterset_form = forms.FrontPortFilterForm
|
||||
table = tables.FrontPortDetailTable
|
||||
table = tables.FrontPortTable
|
||||
action_buttons = ('import', 'export')
|
||||
|
||||
|
||||
@ -1516,7 +1516,7 @@ class FrontPortDeleteView(ObjectDeleteView):
|
||||
class FrontPortBulkImportView(BulkImportView):
|
||||
queryset = FrontPort.objects.all()
|
||||
model_form = forms.FrontPortCSVForm
|
||||
table = tables.FrontPortImportTable
|
||||
table = tables.FrontPortTable
|
||||
default_return_url = 'dcim:frontport_list'
|
||||
|
||||
|
||||
@ -1549,10 +1549,10 @@ class FrontPortBulkDeleteView(BulkDeleteView):
|
||||
#
|
||||
|
||||
class RearPortListView(ObjectListView):
|
||||
queryset = RearPort.objects.prefetch_related('device', 'device__tenant', 'device__site', 'cable')
|
||||
queryset = RearPort.objects.prefetch_related('device', 'cable')
|
||||
filterset = filters.RearPortFilterSet
|
||||
filterset_form = forms.RearPortFilterForm
|
||||
table = tables.RearPortDetailTable
|
||||
table = tables.RearPortTable
|
||||
action_buttons = ('import', 'export')
|
||||
|
||||
|
||||
@ -1579,7 +1579,7 @@ class RearPortDeleteView(ObjectDeleteView):
|
||||
class RearPortBulkImportView(BulkImportView):
|
||||
queryset = RearPort.objects.all()
|
||||
model_form = forms.RearPortCSVForm
|
||||
table = tables.RearPortImportTable
|
||||
table = tables.RearPortTable
|
||||
default_return_url = 'dcim:rearport_list'
|
||||
|
||||
|
||||
@ -1612,12 +1612,10 @@ class RearPortBulkDeleteView(BulkDeleteView):
|
||||
#
|
||||
|
||||
class DeviceBayListView(ObjectListView):
|
||||
queryset = DeviceBay.objects.prefetch_related(
|
||||
'device', 'device__site', 'installed_device', 'installed_device__site'
|
||||
)
|
||||
queryset = DeviceBay.objects.prefetch_related('device', 'installed_device')
|
||||
filterset = filters.DeviceBayFilterSet
|
||||
filterset_form = forms.DeviceBayFilterForm
|
||||
table = tables.DeviceBayDetailTable
|
||||
table = tables.DeviceBayTable
|
||||
action_buttons = ('import', 'export')
|
||||
|
||||
|
||||
@ -1711,7 +1709,7 @@ class DeviceBayDepopulateView(ObjectEditView):
|
||||
class DeviceBayBulkImportView(BulkImportView):
|
||||
queryset = DeviceBay.objects.all()
|
||||
model_form = forms.DeviceBayCSVForm
|
||||
table = tables.DeviceBayImportTable
|
||||
table = tables.DeviceBayTable
|
||||
default_return_url = 'dcim:devicebay_list'
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user