Skip to content

Commit 8a9976a

Browse files
Bastienclaude
andcommitted
Include child locations in rack/device lists for location floorplans
A floorplan attached to a parent location previously offered no racks or devices to place when they are assigned to its child locations, which is the common case for a datacenter location split into rooms/rows. Filter on the location's descendants (including itself) instead of an exact location match. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 383edc4 commit 8a9976a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

netbox_floorplan/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def get(self, request):
119119
site=fp_instance.site.id).order_by("name")
120120
else:
121121
self.queryset = Rack.objects.all().select_related("role").filter(~Q(id__in=fp_instance.mapped_racks)).filter(
122-
location=fp_instance.location.id).order_by("name")
122+
location__in=fp_instance.location.get_descendants(include_self=True)).order_by("name")
123123
return super().get(request)
124124

125125

@@ -135,7 +135,7 @@ def get(self, request):
135135
site=fp_instance.site.id, rack=None).order_by("name")
136136
else:
137137
self.queryset = Device.objects.all().filter(~Q(id__in=fp_instance.mapped_devices)).filter(
138-
location=fp_instance.location.id, rack=None).order_by("name")
138+
location__in=fp_instance.location.get_descendants(include_self=True), rack=None).order_by("name")
139139
return super().get(request)
140140

141141

0 commit comments

Comments
 (0)