Missing checkboxes on Cluster view page (/virtualization/clusters/<#>/) #1733

Closed
opened 2025-12-29 16:34:49 +01:00 by adam · 0 comments
Owner

Originally created by @contemno on GitHub (May 19, 2018).

Issue type

[ ] Feature request
[X] Bug report
[ ] Documentation

Environment

  • Python version: 2.7.5
  • NetBox version: 2.2.7 (I'm aware that I'm behind, but I think this is still an issue. Please see the description and proposed fix below.)

To reproduce the issue:

  1. Navigate to the Cluster view page as a (non-super) user that has the ''virtualization | cluster | Can change cluster" permission.

Expected behavior:

When the user has the ''virtualization | cluster | Can change cluster" permission, display a checkbox in the 'Host Devices' header to select all 'Host Devices' in the list, and checkboxes next to each 'Host Device' in the list.

Error messages:

  1. None

Description

I searched for an existing issue and didn't find anything matching this one. I also looked into the 'develop' or 'develop-2.4' branches and the issue doesn't appear to have been fixed there.

On the Cluster view page the list of Host devices would not display checkboxes despite the user having the ''virtualization | cluster | Can change cluster" permission. The checkboxes would only be displayed for superusers.

Fortunately there seems to be a simple fix. I noticed whenever request.user.has_perm() method is called elsewhere, the permissions argument followed a consistent format of <category>.<permission>, but the specific call in the 'get' method of the 'ClusterView' class was using the format <category>:<permission>, which looks like the return_url format. Simply replacing the colon with a period the permissions argument seems to have corrected the issue.

In '/netbox/netbox/virtualization/views.py':

109 class ClusterView(View):
110 
111     def get(self, request, pk):
112 
113         cluster = get_object_or_404(Cluster, pk=pk)
114         devices = Device.objects.filter(cluster=cluster).select_related(
115             'site', 'rack', 'tenant', 'device_type__manufacturer'
116         )
117         device_table = DeviceTable(list(devices), orderable=False)
118 -       if request.user.has_perm('virtualization:change_cluster'):
118 +       if request.user.has_perm('virtualization.change_cluster'):
119             device_table.columns.show('pk')
120 
121         return render(request, 'virtualization/cluster.html', {
122             'cluster': cluster,
123             'device_table': device_table,
124         })

Best,
Joshua

Originally created by @contemno on GitHub (May 19, 2018). <!-- Before opening a new issue, please search through the existing issues to see if your topic has already been addressed. Note that you may need to remove the "is:open" filter from the search bar to include closed issues. Check the appropriate type for your issue below by placing an x between the brackets. For assistance with installation issues, or for any other issues other than those listed below, please raise your topic for discussion on our mailing list: https://groups.google.com/forum/#!forum/netbox-discuss Please note that issues which do not fall under any of the below categories will be closed. Due to an excessive backlog of feature requests, we are not currently accepting any proposals which extend NetBox's feature scope. Do not prepend any sort of tag to your issue's title. An administrator will review your issue and assign labels as appropriate. ---> ### Issue type [ ] Feature request <!-- An enhancement of existing functionality --> [X] Bug report <!-- Unexpected or erroneous behavior --> [ ] Documentation <!-- A modification to the documentation --> <!-- Please describe the environment in which you are running NetBox. (Be sure to verify that you are running the latest stable release of NetBox before submitting a bug report.) If you are submitting a bug report and have made any changes to the code base, please first validate that your bug can be recreated while running an official release. --> ### Environment * Python version: 2.7.5 * NetBox version: 2.2.7 (I'm aware that I'm behind, but I think this is still an issue. Please see the description and proposed fix below.) #### To reproduce the issue: 1. Navigate to the Cluster view page as a (non-super) user that has the ''virtualization | cluster | Can change cluster" permission. #### Expected behavior: When the user has the ''virtualization | cluster | Can change cluster" permission, display a checkbox in the 'Host Devices' header to select all 'Host Devices' in the list, and checkboxes next to each 'Host Device' in the list. #### Error messages: 1. None <!-- BUG REPORTS must include: * A list of the steps needed for someone else to reproduce the bug * A description of the expected and observed behavior * Any relevant error messages (screenshots may also help) FEATURE REQUESTS must include: * A detailed description of the proposed functionality * A use case for the new feature * A rough description of any necessary changes to the database schema * Any relevant third-party libraries which would be needed --> ### Description I searched for an existing issue and didn't find anything matching this one. I also looked into the 'develop' or 'develop-2.4' branches and the issue doesn't appear to have been fixed there. On the Cluster view page the list of Host devices would not display checkboxes despite the user having the ''virtualization | cluster | Can change cluster" permission. The checkboxes would only be displayed for superusers. Fortunately there seems to be a simple fix. I noticed whenever `request.user.has_perm()` method is called elsewhere, the permissions argument followed a consistent format of `<category>`.`<permission>`, but the specific call in the 'get' method of the 'ClusterView' class was using the format `<category>`:`<permission>`, which looks like the return_url format. Simply replacing the colon with a period the permissions argument seems to have corrected the issue. In '[/netbox/netbox/virtualization/views.py](https://github.com/digitalocean/netbox/blob/e5454d6714a6f3b42166e774e7ed2dd244f63d5a/netbox/virtualization/views.py#L118)': ```python 109 class ClusterView(View): 110 111 def get(self, request, pk): 112 113 cluster = get_object_or_404(Cluster, pk=pk) 114 devices = Device.objects.filter(cluster=cluster).select_related( 115 'site', 'rack', 'tenant', 'device_type__manufacturer' 116 ) 117 device_table = DeviceTable(list(devices), orderable=False) 118 - if request.user.has_perm('virtualization:change_cluster'): 118 + if request.user.has_perm('virtualization.change_cluster'): 119 device_table.columns.show('pk') 120 121 return render(request, 'virtualization/cluster.html', { 122 'cluster': cluster, 123 'device_table': device_table, 124 }) ``` Best, Joshua
adam added the type: bugstatus: accepted labels 2025-12-29 16:34:49 +01:00
adam closed this issue 2025-12-29 16:34:49 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#1733