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

Fixes #8671: Fix AttributeError when viewing console/power/interface connection lists

jeremystretch 4 лет назад
Родитель
Сommit
90558a2e80
2 измененных файлов с 25 добавлено и 24 удалено
  1. 1 0
      docs/release-notes/version-3.2.md
  2. 24 24
      netbox/netbox/tables/tables.py

+ 1 - 0
docs/release-notes/version-3.2.md

@@ -149,6 +149,7 @@ Where it is desired to limit the range of available VLANs within a group, users
 * [#8655](https://github.com/netbox-community/netbox/issues/8655) - Fix AttributeError when viewing cabled interfaces
 * [#8659](https://github.com/netbox-community/netbox/issues/8659) - Fix display of multi-object custom fields after deleting related object
 * [#8661](https://github.com/netbox-community/netbox/issues/8661) - Fix ValueError exception when trying to connect a cable
+* [#8671](https://github.com/netbox-community/netbox/issues/8671) - Fix AttributeError when viewing console/power/interface connection lists
 
 ### Other Changes
 

+ 24 - 24
netbox/netbox/tables/tables.py

@@ -127,6 +127,30 @@ class BaseTable(tables.Table):
             self._objects_count = sum(1 for obj in self.data if hasattr(obj, 'pk'))
         return self._objects_count
 
+    def configure(self, request):
+        """
+        Configure the table for a specific request context. This performs pagination and records
+        the user's preferred ordering logic.
+        """
+        # Save ordering preference
+        if request.user.is_authenticated:
+            table_name = self.__class__.__name__
+            if self.prefixed_order_by_field in request.GET:
+                # If an ordering has been specified as a query parameter, save it as the
+                # user's preferred ordering for this table.
+                ordering = request.GET.getlist(self.prefixed_order_by_field)
+                request.user.config.set(f'tables.{table_name}.ordering', ordering, commit=True)
+            elif ordering := request.user.config.get(f'tables.{table_name}.ordering'):
+                # If no ordering has been specified, set the preferred ordering (if any).
+                self.order_by = ordering
+
+        # Paginate the table results
+        paginate = {
+            'paginator_class': EnhancedPaginator,
+            'per_page': get_paginate_count(request)
+        }
+        tables.RequestConfig(request, paginate).configure(self)
+
 
 class NetBoxTable(BaseTable):
     """
@@ -167,27 +191,3 @@ class NetBoxTable(BaseTable):
         ])
 
         super().__init__(*args, extra_columns=extra_columns, **kwargs)
-
-    def configure(self, request):
-        """
-        Configure the table for a specific request context. This performs pagination and records
-        the user's preferred ordering logic.
-        """
-        # Save ordering preference
-        if request.user.is_authenticated:
-            table_name = self.__class__.__name__
-            if self.prefixed_order_by_field in request.GET:
-                # If an ordering has been specified as a query parameter, save it as the
-                # user's preferred ordering for this table.
-                ordering = request.GET.getlist(self.prefixed_order_by_field)
-                request.user.config.set(f'tables.{table_name}.ordering', ordering, commit=True)
-            elif ordering := request.user.config.get(f'tables.{table_name}.ordering'):
-                # If no ordering has been specified, set the preferred ordering (if any).
-                self.order_by = ordering
-
-        # Paginate the table results
-        paginate = {
-            'paginator_class': EnhancedPaginator,
-            'per_page': get_paginate_count(request)
-        }
-        tables.RequestConfig(request, paginate).configure(self)