mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Modify default CSV export to render from tables
This commit is contained in:
@@ -2530,23 +2530,6 @@ class ConsoleConnectionsListView(generic.ObjectListView):
|
||||
table = tables.ConsoleConnectionTable
|
||||
template_name = 'dcim/connections_list.html'
|
||||
|
||||
def queryset_to_csv(self):
|
||||
csv_data = [
|
||||
# Headers
|
||||
','.join(['console_server', 'port', 'device', 'console_port', 'reachable'])
|
||||
]
|
||||
for obj in self.queryset:
|
||||
csv = csv_format([
|
||||
obj._path.destination.device.identifier if obj._path.destination else None,
|
||||
obj._path.destination.name if obj._path.destination else None,
|
||||
obj.device.identifier,
|
||||
obj.name,
|
||||
obj._path.is_active
|
||||
])
|
||||
csv_data.append(csv)
|
||||
|
||||
return '\n'.join(csv_data)
|
||||
|
||||
def extra_context(self):
|
||||
return {
|
||||
'title': 'Console Connections'
|
||||
@@ -2560,23 +2543,6 @@ class PowerConnectionsListView(generic.ObjectListView):
|
||||
table = tables.PowerConnectionTable
|
||||
template_name = 'dcim/connections_list.html'
|
||||
|
||||
def queryset_to_csv(self):
|
||||
csv_data = [
|
||||
# Headers
|
||||
','.join(['pdu', 'outlet', 'device', 'power_port', 'reachable'])
|
||||
]
|
||||
for obj in self.queryset:
|
||||
csv = csv_format([
|
||||
obj._path.destination.device.identifier if obj._path.destination else None,
|
||||
obj._path.destination.name if obj._path.destination else None,
|
||||
obj.device.identifier,
|
||||
obj.name,
|
||||
obj._path.is_active
|
||||
])
|
||||
csv_data.append(csv)
|
||||
|
||||
return '\n'.join(csv_data)
|
||||
|
||||
def extra_context(self):
|
||||
return {
|
||||
'title': 'Power Connections'
|
||||
@@ -2594,25 +2560,6 @@ class InterfaceConnectionsListView(generic.ObjectListView):
|
||||
table = tables.InterfaceConnectionTable
|
||||
template_name = 'dcim/connections_list.html'
|
||||
|
||||
def queryset_to_csv(self):
|
||||
csv_data = [
|
||||
# Headers
|
||||
','.join([
|
||||
'device_a', 'interface_a', 'device_b', 'interface_b', 'reachable'
|
||||
])
|
||||
]
|
||||
for obj in self.queryset:
|
||||
csv = csv_format([
|
||||
obj._path.destination.device.identifier if obj._path.destination else None,
|
||||
obj._path.destination.name if obj._path.destination else None,
|
||||
obj.device.identifier,
|
||||
obj.name,
|
||||
obj._path.is_active
|
||||
])
|
||||
csv_data.append(csv)
|
||||
|
||||
return '\n'.join(csv_data)
|
||||
|
||||
def extra_context(self):
|
||||
return {
|
||||
'title': 'Interface Connections'
|
||||
|
Reference in New Issue
Block a user