From bb988701fe8262305eb008b5f954a7021d8e4db3 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Thu, 29 Apr 2021 08:43:46 -0400 Subject: [PATCH] Fixes #6308: Fix linking of available VLANs in VLAN group view --- docs/release-notes/version-2.11.md | 4 ++++ netbox/ipam/views.py | 8 ++++++++ netbox/templates/ipam/vlangroup.html | 26 +++++++++++--------------- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/docs/release-notes/version-2.11.md b/docs/release-notes/version-2.11.md index 94c7a984f..1ec3e0fdf 100644 --- a/docs/release-notes/version-2.11.md +++ b/docs/release-notes/version-2.11.md @@ -6,6 +6,10 @@ * [#6197](https://github.com/netbox-community/netbox/issues/6197) - Introduced `SESSION_COOKIE_NAME` config parameter +### Bug Fixes + +* [#6308](https://github.com/netbox-community/netbox/issues/6308) - Fix linking of available VLANs in VLAN group view + --- ## v2.11.2 (2021-04-27) diff --git a/netbox/ipam/views.py b/netbox/ipam/views.py index 0339aff07..f7da1f583 100644 --- a/netbox/ipam/views.py +++ b/netbox/ipam/views.py @@ -684,9 +684,17 @@ class VLANGroupView(generic.ObjectView): vlans_table.columns.hide('group') paginate_table(vlans_table, request) + # Compile permissions list for rendering the object table + permissions = { + 'add': request.user.has_perm('ipam.add_vlan'), + 'change': request.user.has_perm('ipam.change_vlan'), + 'delete': request.user.has_perm('ipam.delete_vlan'), + } + return { 'vlans_count': vlans_count, 'vlans_table': vlans_table, + 'permissions': permissions, } diff --git a/netbox/templates/ipam/vlangroup.html b/netbox/templates/ipam/vlangroup.html index 3118c1796..67330ef80 100644 --- a/netbox/templates/ipam/vlangroup.html +++ b/netbox/templates/ipam/vlangroup.html @@ -10,6 +10,15 @@
  • {{ object }}
  • {% endblock %} +{% block buttons %} + {% if perms.ipam.add_vlan %} + + Add VLAN + + {% endif %} + {{ block.super }} +{% endblock %} + {% block content %}
    @@ -52,21 +61,8 @@
    -
    -
    - VLANs -
    - {% include 'inc/table.html' with table=vlans_table %} - {% if perms.ipam.add_vlan %} - - {% endif %} -
    - {% include 'inc/paginator.html' with paginator=vlans_table.paginator page=vlans_table.page %} -
    + {% include 'utilities/obj_table.html' with table=vlans_table table_template='panel_table.html' heading='VLANs' bulk_edit_url='ipam:vlan_bulk_edit' bulk_delete_url='ipam:vlan_bulk_delete' %} +
    {% endblock %}