From bb4f21d5ee60532ef84fe463727b06b01ade3902 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 24 Jul 2020 09:16:14 -0400 Subject: [PATCH] Fixes #4894: Fix display of device/VM counts on platforms list --- docs/release-notes/version-2.8.md | 3 ++- netbox/dcim/tables.py | 24 ++++++++++++++++-------- netbox/dcim/views.py | 4 ++-- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/docs/release-notes/version-2.8.md b/docs/release-notes/version-2.8.md index 774de491a..5a55fb6e1 100644 --- a/docs/release-notes/version-2.8.md +++ b/docs/release-notes/version-2.8.md @@ -6,8 +6,9 @@ * [#4875](https://github.com/netbox-community/netbox/issues/4875) - Fix documentation for image attachments * [#4876](https://github.com/netbox-community/netbox/issues/4876) - Fix labels for sites in staging or decommissioning status -* [#4880](https://github.com/netbox-community/netbox/issues/4880) - Fix remove tagged vlans if not assigned in bulk interface editting +* [#4880](https://github.com/netbox-community/netbox/issues/4880) - Fix removal of tagged VLANs if not assigned in bulk interface editing * [#4887](https://github.com/netbox-community/netbox/issues/4887) - Don't disable NAPALM tabs when device has no primary IP +* [#4894](https://github.com/netbox-community/netbox/issues/4894) - Fix display of device/VM counts on platforms list --- diff --git a/netbox/dcim/tables.py b/netbox/dcim/tables.py index e7fd6ae11..5a1b06bed 100644 --- a/netbox/dcim/tables.py +++ b/netbox/dcim/tables.py @@ -94,6 +94,14 @@ MANUFACTURER_ACTIONS = """ {% endif %} """ +DEVICEROLE_DEVICE_COUNT = """ +{{ value|default:0 }} +""" + +DEVICEROLE_VM_COUNT = """ +{{ value|default:0 }} +""" + DEVICEROLE_ACTIONS = """ @@ -103,12 +111,12 @@ DEVICEROLE_ACTIONS = """ {% endif %} """ -DEVICE_COUNT = """ -{{ value|default:0 }} +PLATFORM_DEVICE_COUNT = """ +{{ value|default:0 }} """ -VM_COUNT = """ -{{ value|default:0 }} +PLATFORM_VM_COUNT = """ +{{ value|default:0 }} """ PLATFORM_ACTIONS = """ @@ -697,11 +705,11 @@ class DeviceBayTemplateTable(BaseTable): class DeviceRoleTable(BaseTable): pk = ToggleColumn() device_count = tables.TemplateColumn( - template_code=DEVICE_COUNT, + template_code=DEVICEROLE_DEVICE_COUNT, verbose_name='Devices' ) vm_count = tables.TemplateColumn( - template_code=VM_COUNT, + template_code=DEVICEROLE_VM_COUNT, verbose_name='VMs' ) color = tables.TemplateColumn( @@ -728,11 +736,11 @@ class DeviceRoleTable(BaseTable): class PlatformTable(BaseTable): pk = ToggleColumn() device_count = tables.TemplateColumn( - template_code=DEVICE_COUNT, + template_code=PLATFORM_DEVICE_COUNT, verbose_name='Devices' ) vm_count = tables.TemplateColumn( - template_code=VM_COUNT, + template_code=PLATFORM_VM_COUNT, verbose_name='VMs' ) actions = tables.TemplateColumn( diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py index bb5182a83..e193813d2 100644 --- a/netbox/dcim/views.py +++ b/netbox/dcim/views.py @@ -1060,8 +1060,8 @@ class DeviceRoleBulkDeleteView(PermissionRequiredMixin, BulkDeleteView): class PlatformListView(PermissionRequiredMixin, ObjectListView): permission_required = 'dcim.view_platform' queryset = Platform.objects.annotate( - device_count=get_subquery(Device, 'device_role'), - vm_count=get_subquery(VirtualMachine, 'role') + device_count=get_subquery(Device, 'platform'), + vm_count=get_subquery(VirtualMachine, 'platform') ) table = tables.PlatformTable