Browse Source

Fixes #21845: Remove whitespace from connection values in interface CSV exports (#21850)

Jeremy Stretch 23 hours ago
parent
commit
1ebeb71ad8
1 changed files with 20 additions and 0 deletions
  1. 20 0
      netbox/dcim/tables/devices.py

+ 20 - 0
netbox/dcim/tables/devices.py

@@ -382,6 +382,17 @@ class PathEndpointTable(CableTerminationTable):
         orderable=False
         orderable=False
     )
     )
 
 
+    def value_connection(self, value):
+        if value:
+            connections = []
+            for termination in value:
+                if hasattr(termination, 'parent_object'):
+                    connections.append(f'{termination.parent_object} > {termination}')
+                else:
+                    connections.append(str(termination))
+            return ', '.join(connections)
+        return None
+
 
 
 class ConsolePortTable(ModularDeviceComponentTable, PathEndpointTable):
 class ConsolePortTable(ModularDeviceComponentTable, PathEndpointTable):
     device = tables.Column(
     device = tables.Column(
@@ -683,6 +694,15 @@ class InterfaceTable(BaseInterfaceTable, ModularDeviceComponentTable, PathEndpoi
         orderable=False
         orderable=False
     )
     )
 
 
+    def value_connection(self, record, value):
+        if record.is_virtual and hasattr(record, 'virtual_circuit_termination') and record.virtual_circuit_termination:
+            connections = [
+                f"{t.interface.parent_object} > {t.interface} via {t.parent_object}"
+                for t in record.connected_endpoints
+            ]
+            return ', '.join(connections)
+        return super().value_connection(value)
+
     class Meta(DeviceComponentTable.Meta):
     class Meta(DeviceComponentTable.Meta):
         model = models.Interface
         model = models.Interface
         fields = (
         fields = (