From 702ef79c76fe9ec75e1a2fbd93a28a6f03bc7ed9 Mon Sep 17 00:00:00 2001 From: Daniel Sheppard Date: Thu, 7 Mar 2024 16:22:28 -0600 Subject: [PATCH] Fixes: #7 - Allow devices in Child Locations --- netbox_floorplan/views.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/netbox_floorplan/views.py b/netbox_floorplan/views.py index d8e4920..d8cc9d8 100644 --- a/netbox_floorplan/views.py +++ b/netbox_floorplan/views.py @@ -113,8 +113,9 @@ def get(self, request): self.queryset = Rack.objects.all().filter(~Q(id__in=fp_instance.mapped_racks)).filter( site=fp_instance.site.id).order_by("name") else: + locations = Location.objects.get(pk=fp_instance.location.id).get_descendants(include_self=True) self.queryset = Rack.objects.all().filter(~Q(id__in=fp_instance.mapped_racks)).filter( - location=fp_instance.location.id).order_by("name") + location__in=locations).order_by("name") return super().get(request) @@ -129,6 +130,7 @@ def get(self, request): self.queryset = Device.objects.all().filter(~Q(id__in=fp_instance.mapped_devices)).filter( site=fp_instance.site.id).order_by("name") else: + locations = Location.objects.get(pk=fp_instance.location.id).get_descendants(include_self=True) self.queryset = Device.objects.all().filter(~Q(id__in=fp_instance.mapped_devices)).filter( - location=fp_instance.location.id).order_by("name") + location__in=locations).order_by("name") return super().get(request)