Fixes: #7 - Allow devices in Child Locations#9
Fixes: #7 - Allow devices in Child Locations#9DanSheps wants to merge 2 commits intonetbox-community:masterfrom
Conversation
|
@natm Can't assign reviewers for some reason. If you could give this a look see that would be great. |
|
Can someone review and approve this so I can start testing this in my dev environment? Is this something I can do? |
dionrowney
left a comment
There was a problem hiding this comment.
Actually I see all devices and racks rather than just racks in the current location and sub locations. It solves the problem but I was not expecting to see ALL objects.
dionrowney
left a comment
There was a problem hiding this comment.
Upon closer investigation it seems to be a UI error that causes the list to display everything. I would say the initial list displayed is correct and I will submit a bug for this new error once this change is in the main branch
|
The patch working well with rack. class FloorplanDeviceListView(generic.ObjectListView):
queryset = Device.objects.all()
table = tables.FloorplanDeviceTable
def get(self, request):
fp_id = request.GET["floorplan_id"]
fp_instance = models.Floorplan.objects.get(pk=fp_id)
if fp_instance.record_type == "site":
self.queryset = Device.objects.all().filter(~Q(id__in=fp_instance.mapped_devices)).filter(
site=fp_instance.site.id).order_by("name")
else:
fp_locations = Location.objects.get(pk=fp_instance.location.id).get_descendants(include_self=True)
fp_racks = Rack.objects.all().filter(location__in=fp_locations)
self.queryset = Device.objects.all().filter(~Q(id__in=fp_instance.mapped_devices)).filter(
location__in=fp_locations).exclude(rack__in=fp_racks).order_by("name")
return super().get(request)The idea is to exclude the devices that are already racked in a rack inside this location |
I've given this a test and it works quite well. I've just manipulated the views.py script to change the function for Devices to this and it worked for me as expected. |
Fixes: #7 - Allow devices in Child Locations