Skip to content

Commit

Permalink
Fixes #2845: Enable filtering of rack unit list by unit ID
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremystretch committed Feb 6, 2019
1 parent 73c9835 commit ca51fab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions netbox/dcim/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ def units(self, request, pk=None):
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})
Expand Down

0 comments on commit ca51fab

Please sign in to comment.