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

Fixes #2845: Enable filtering of rack unit list by unit ID

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

+ 1 - 0
CHANGELOG.md

@@ -3,6 +3,7 @@ v2.5.6 (FUTURE)
 ## Bug Fixes
 
 * [#2844](https://github.com/digitalocean/netbox/issues/2844) - Correct display of far cable end for pass-through ports
+* [#2845](https://github.com/digitalocean/netbox/issues/2845) - Enable filtering of rack unit list by unit ID
 * [#2856](https://github.com/digitalocean/netbox/issues/2856) - Fix navigation links between LAG interfaces and their members on device view
 * [#2857](https://github.com/digitalocean/netbox/issues/2857) - Add `display_name` to DeviceType API serializer; fix DeviceType list for bulk device edit
 

+ 5 - 0
netbox/dcim/api/views.py

@@ -159,6 +159,11 @@ class RackViewSet(CustomFieldModelViewSet):
                 exclude_pk = None
         elevation = rack.get_rack_units(face, exclude_pk)
 
+        # Enable filtering rack units by ID
+        q = request.GET.get('q', None)
+        if q:
+            elevation = [u for u in elevation if q in str(u['id'])]
+
         page = self.paginate_queryset(elevation)
         if page is not None:
             rack_units = serializers.RackUnitSerializer(page, many=True, context={'request': request})