Просмотр исходного кода

Closes #2057: Added description columns to interface connections list

Jeremy Stretch 7 лет назад
Родитель
Сommit
e57b3bc4ab
3 измененных файлов с 12 добавлено и 1 удалено
  1. 1 0
      CHANGELOG.md
  2. 9 1
      netbox/dcim/tables.py
  3. 2 0
      netbox/dcim/views.py

+ 1 - 0
CHANGELOG.md

@@ -27,6 +27,7 @@ NetBox now supports modeling physical cables for console, power, and interface c
 * [#1444](https://github.com/digitalocean/netbox/issues/1444) - Added an `asset_tag` field for racks
 * [#1931](https://github.com/digitalocean/netbox/issues/1931) - Added a count of assigned IP addresses to the interface API serializer
 * [#2000](https://github.com/digitalocean/netbox/issues/2000) - Dropped support for Python 2
+* [#2057](https://github.com/digitalocean/netbox/issues/2057) - Added description columns to interface connections list
 * [#2104](https://github.com/digitalocean/netbox/issues/2104) - Added a `status` field for racks
 * [#2165](https://github.com/digitalocean/netbox/issues/2165) - Improved natural ordering of Interfaces
 * [#2292](https://github.com/digitalocean/netbox/issues/2292) - Removed the deprecated UserAction model

+ 9 - 1
netbox/dcim/tables.py

@@ -716,6 +716,10 @@ class InterfaceConnectionTable(BaseTable):
         args=[Accessor('pk')],
         verbose_name='Interface A'
     )
+    description_a = tables.Column(
+        accessor=Accessor('description'),
+        verbose_name='Description'
+    )
     device_b = tables.LinkColumn(
         viewname='dcim:device',
         accessor=Accessor('connected_endpoint.device'),
@@ -728,6 +732,10 @@ class InterfaceConnectionTable(BaseTable):
         args=[Accessor('connected_endpoint.pk')],
         verbose_name='Interface B'
     )
+    description_b = tables.Column(
+        accessor=Accessor('connected_endpoint.description'),
+        verbose_name='Description'
+    )
     cable = tables.LinkColumn(
         viewname='dcim:cable',
         args=[Accessor('cable.pk')]
@@ -735,7 +743,7 @@ class InterfaceConnectionTable(BaseTable):
 
     class Meta(BaseTable.Meta):
         model = Interface
-        fields = ('device_a', 'interface_a', 'device_b', 'interface_b', 'cable')
+        fields = ('device_a', 'interface_a', 'description_a', 'device_b', 'interface_b', 'description_b', 'cable')
 
 
 #

+ 2 - 0
netbox/dcim/views.py

@@ -1732,6 +1732,8 @@ class InterfaceConnectionsListView(ObjectListView):
         # Avoid duplicate connections by only selecting the lower PK in a connected pair
         _connected_interface__isnull=False,
         pk__lt=F('_connected_interface')
+    ).order_by(
+        'device'
     )
     filter = filters.InterfaceConnectionFilter
     filter_form = forms.InterfaceConnectionFilterForm