Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
contemno opened this issue May 18, 2018 · 0 comments · Fixed by #2099
Closed

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

contemno opened this issue May 18, 2018 · 0 comments · Fixed by #2099
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@contemno
Copy link

contemno commented May 18, 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

@jeremystretch jeremystretch added type: bug A confirmed report of unexpected behavior in the application status: accepted This issue has been accepted for implementation labels May 21, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jan 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants