From 9d243103f494923ed97538ad866526688d4809e9 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Thu, 16 Jul 2020 15:45:27 -0400 Subject: [PATCH] Fixes #4595: Ensure consistent display of non-racked and child devices on rack view --- docs/release-notes/version-2.8.md | 1 + netbox/dcim/views.py | 5 +++-- netbox/templates/dcim/rack.html | 15 +++++++-------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/docs/release-notes/version-2.8.md b/docs/release-notes/version-2.8.md index b07f1d7dd..7a782329f 100644 --- a/docs/release-notes/version-2.8.md +++ b/docs/release-notes/version-2.8.md @@ -12,6 +12,7 @@ ### Bug Fixes * [#3240](https://github.com/netbox-community/netbox/issues/3240) - Correct OpenAPI definition for available-prefixes endpoint +* [#4595](https://github.com/netbox-community/netbox/issues/4595) - Ensure consistent display of non-racked and child devices on rack view * [#4803](https://github.com/netbox-community/netbox/issues/4803) - Return IP family (4 or 6) as integer rather than string * [#4821](https://github.com/netbox-community/netbox/issues/4821) - Restrict group options by selected site when bulk editing VLANs * [#4835](https://github.com/netbox-community/netbox/issues/4835) - Support passing multiple initial values for multiple choice fields diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py index 748e41139..bb5182a83 100644 --- a/netbox/dcim/views.py +++ b/netbox/dcim/views.py @@ -399,11 +399,12 @@ class RackView(PermissionRequiredMixin, View): rack = get_object_or_404(Rack.objects.prefetch_related('site__region', 'tenant__group', 'group', 'role'), pk=pk) + # Get 0U and child devices located within the rack nonracked_devices = Device.objects.filter( rack=rack, - position__isnull=True, - parent_bay__isnull=True + position__isnull=True ).prefetch_related('device_type__manufacturer') + if rack.group: peer_racks = Rack.objects.filter(site=rack.site, group=rack.group) else: diff --git a/netbox/templates/dcim/rack.html b/netbox/templates/dcim/rack.html index 20e31151d..124aeeeda 100644 --- a/netbox/templates/dcim/rack.html +++ b/netbox/templates/dcim/rack.html @@ -337,7 +337,7 @@ Name Role Type - Parent + Parent Device {% for device in nonracked_devices %} @@ -346,13 +346,12 @@ {{ device.device_role }} {{ device.device_type.display_name }} - - {% if device.parent_bay %} - {{ device.parent_bay }} - {% else %} - - {% endif %} - + {% if device.parent_bay %} + {{ device.parent_bay.device }} + {{ device.parent_bay }} + {% else %} + — + {% endif %} {% endfor %}