From 4f36885c5ec97ae2550598d27607d3acaa2f1a5b Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Tue, 31 Aug 2021 09:13:34 -0400 Subject: [PATCH 01/12] Fixes #7096: Home links should honor BASE_PATH configuration --- docs/release-notes/version-3.0.md | 3 ++- netbox/templates/base/sidenav.html | 4 ++-- netbox/templates/media_failure.html | 2 +- netbox/templates/rest_framework/api.html | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/release-notes/version-3.0.md b/docs/release-notes/version-3.0.md index fd7603c0e..e33ef2663 100644 --- a/docs/release-notes/version-3.0.md +++ b/docs/release-notes/version-3.0.md @@ -1,11 +1,12 @@ # NetBox v3.0 -## v2.11.12 (2021-08-23) +## v3.0.1 (FUTURE) ### Bug Fixes * [#7070](https://github.com/netbox-community/netbox/issues/7070) - Fix exception when filtering by prefix max length in UI * [#7071](https://github.com/netbox-community/netbox/issues/7071) - Fix exception when removing a primary IP from a device/VM +* [#7096](https://github.com/netbox-community/netbox/issues/7096) - Home links should honor `BASE_PATH` configuration --- diff --git a/netbox/templates/base/sidenav.html b/netbox/templates/base/sidenav.html index 8941171e5..5790e8c44 100644 --- a/netbox/templates/base/sidenav.html +++ b/netbox/templates/base/sidenav.html @@ -7,12 +7,12 @@ {# Brand #} {# Full Logo #} - + NetBox Logo {# Icon Logo #} - + NetBox Logo diff --git a/netbox/templates/media_failure.html b/netbox/templates/media_failure.html index 10b01291d..e3b7ef309 100644 --- a/netbox/templates/media_failure.html +++ b/netbox/templates/media_failure.html @@ -42,7 +42,7 @@ The file {{ filename }} exists in the static root directory and is readable by the HTTP process. -

Click here to attempt loading NetBox again.

+

Click here to attempt loading NetBox again.

diff --git a/netbox/templates/rest_framework/api.html b/netbox/templates/rest_framework/api.html index 36bf7a554..7ece5905c 100644 --- a/netbox/templates/rest_framework/api.html +++ b/netbox/templates/rest_framework/api.html @@ -9,5 +9,5 @@ {% block title %}{% if name %}{{ name }} | {% endif %}NetBox REST API{% endblock %} {% block branding %} - NetBox + NetBox {% endblock branding %} From 30909813357e5714d9f43c756d6ab3ce9ab11217 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Tue, 31 Aug 2021 09:39:49 -0400 Subject: [PATCH 02/12] Fixes #7084: Fix KeyError exception when editing access VLAN on an interface --- docs/release-notes/version-3.0.md | 1 + netbox/dcim/forms.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/release-notes/version-3.0.md b/docs/release-notes/version-3.0.md index e33ef2663..c31de7e63 100644 --- a/docs/release-notes/version-3.0.md +++ b/docs/release-notes/version-3.0.md @@ -6,6 +6,7 @@ * [#7070](https://github.com/netbox-community/netbox/issues/7070) - Fix exception when filtering by prefix max length in UI * [#7071](https://github.com/netbox-community/netbox/issues/7071) - Fix exception when removing a primary IP from a device/VM +* [#7084](https://github.com/netbox-community/netbox/issues/7084) - Fix KeyError exception when editing access VLAN on an interface * [#7096](https://github.com/netbox-community/netbox/issues/7096) - Home links should honor `BASE_PATH` configuration --- diff --git a/netbox/dcim/forms.py b/netbox/dcim/forms.py index b69944cf6..96a58a0c3 100644 --- a/netbox/dcim/forms.py +++ b/netbox/dcim/forms.py @@ -129,7 +129,7 @@ class InterfaceCommonForm(forms.Form): super().clean() parent_field = 'device' if 'device' in self.cleaned_data else 'virtual_machine' - tagged_vlans = self.cleaned_data['tagged_vlans'] + tagged_vlans = self.cleaned_data.get('tagged_vlans') # Untagged interfaces cannot be assigned tagged VLANs if self.cleaned_data['mode'] == InterfaceModeChoices.MODE_ACCESS and tagged_vlans: @@ -142,7 +142,7 @@ class InterfaceCommonForm(forms.Form): self.cleaned_data['tagged_vlans'] = [] # Validate tagged VLANs; must be a global VLAN or in the same site - elif self.cleaned_data['mode'] == InterfaceModeChoices.MODE_TAGGED: + elif self.cleaned_data['mode'] == InterfaceModeChoices.MODE_TAGGED and tagged_vlans: valid_sites = [None, self.cleaned_data[parent_field].site] invalid_vlans = [str(v) for v in tagged_vlans if v.site not in valid_sites] From 65c93396877dad85e2864f3b5834f2af04ca959d Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Tue, 31 Aug 2021 09:41:54 -0400 Subject: [PATCH 03/12] Fixes #7083: Correct labeling for VM memory attribute --- docs/release-notes/version-3.0.md | 1 + netbox/templates/virtualization/virtualmachine.html | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/release-notes/version-3.0.md b/docs/release-notes/version-3.0.md index c31de7e63..160f8b892 100644 --- a/docs/release-notes/version-3.0.md +++ b/docs/release-notes/version-3.0.md @@ -6,6 +6,7 @@ * [#7070](https://github.com/netbox-community/netbox/issues/7070) - Fix exception when filtering by prefix max length in UI * [#7071](https://github.com/netbox-community/netbox/issues/7071) - Fix exception when removing a primary IP from a device/VM +* [#7083](https://github.com/netbox-community/netbox/issues/7083) - Correct labeling for VM memory attribute * [#7084](https://github.com/netbox-community/netbox/issues/7084) - Fix KeyError exception when editing access VLAN on an interface * [#7096](https://github.com/netbox-community/netbox/issues/7096) - Home links should honor `BASE_PATH` configuration diff --git a/netbox/templates/virtualization/virtualmachine.html b/netbox/templates/virtualization/virtualmachine.html index 6ea4e8d7c..249ef91e4 100644 --- a/netbox/templates/virtualization/virtualmachine.html +++ b/netbox/templates/virtualization/virtualmachine.html @@ -131,7 +131,7 @@ Memory {% if object.memory %} - {{ object.memory|humanize_megabytes }} MB + {{ object.memory|humanize_megabytes }} {% else %} {% endif %} From 8036d1e5a51dca180b85f576e6a4f4bcaa3563de Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Tue, 31 Aug 2021 09:50:24 -0400 Subject: [PATCH 04/12] Fixes #7078: Restore styling on server error page --- netbox/templates/500.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/netbox/templates/500.html b/netbox/templates/500.html index 427345e56..e0207f74d 100644 --- a/netbox/templates/500.html +++ b/netbox/templates/500.html @@ -4,7 +4,7 @@ Server Error - + @@ -12,7 +12,7 @@
-
+
Server Error
From 7db2b9d0916496ae65524fe21048a070a6b601f0 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Tue, 31 Aug 2021 11:15:41 -0400 Subject: [PATCH 05/12] Fixes #7072: Fix table configuration under prefix child object views --- docs/release-notes/version-3.0.md | 1 + netbox/ipam/views.py | 9 ++++----- netbox/netbox/views/generic.py | 1 - netbox/templates/ipam/prefix/ip_addresses.html | 8 ++++++++ netbox/templates/ipam/prefix/ip_ranges.html | 9 ++++++++- netbox/templates/ipam/prefix/prefixes.html | 16 +++++++--------- .../templatetags/table_config_form.html | 10 +++++----- netbox/utilities/templatetags/helpers.py | 2 +- 8 files changed, 34 insertions(+), 22 deletions(-) diff --git a/docs/release-notes/version-3.0.md b/docs/release-notes/version-3.0.md index 160f8b892..e88d1fc6f 100644 --- a/docs/release-notes/version-3.0.md +++ b/docs/release-notes/version-3.0.md @@ -6,6 +6,7 @@ * [#7070](https://github.com/netbox-community/netbox/issues/7070) - Fix exception when filtering by prefix max length in UI * [#7071](https://github.com/netbox-community/netbox/issues/7071) - Fix exception when removing a primary IP from a device/VM +* [#7072](https://github.com/netbox-community/netbox/issues/7072) - Fix table configuration under prefix child object views * [#7083](https://github.com/netbox-community/netbox/issues/7083) - Correct labeling for VM memory attribute * [#7084](https://github.com/netbox-community/netbox/issues/7084) - Fix KeyError exception when editing access VLAN on an interface * [#7096](https://github.com/netbox-community/netbox/issues/7096) - Home links should honor `BASE_PATH` configuration diff --git a/netbox/ipam/views.py b/netbox/ipam/views.py index eed03885e..5151fdd20 100644 --- a/netbox/ipam/views.py +++ b/netbox/ipam/views.py @@ -404,12 +404,11 @@ class PrefixPrefixesView(generic.ObjectView): bulk_querystring = 'vrf_id={}&within={}'.format(instance.vrf.pk if instance.vrf else '0', instance.prefix) return { - 'first_available_prefix': instance.get_first_available_prefix(), 'table': table, 'bulk_querystring': bulk_querystring, 'active_tab': 'prefixes', + 'first_available_prefix': instance.get_first_available_prefix(), 'show_available': request.GET.get('show_available', 'true') == 'true', - 'table_config_form': TableConfigForm(table=table), } @@ -421,7 +420,7 @@ class PrefixIPRangesView(generic.ObjectView): # Find all IPRanges belonging to this Prefix ip_ranges = instance.get_child_ranges().restrict(request.user, 'view').prefetch_related('vrf') - table = tables.IPRangeTable(ip_ranges) + table = tables.IPRangeTable(ip_ranges, user=request.user) if request.user.has_perm('ipam.change_iprange') or request.user.has_perm('ipam.delete_iprange'): table.columns.show('pk') paginate_table(table, request) @@ -449,7 +448,7 @@ class PrefixIPAddressesView(generic.ObjectView): if request.GET.get('show_available', 'true') == 'true': ipaddresses = add_available_ipaddresses(instance.prefix, ipaddresses, instance.is_pool) - table = tables.IPAddressTable(ipaddresses) + table = tables.IPAddressTable(ipaddresses, user=request.user) if request.user.has_perm('ipam.change_ipaddress') or request.user.has_perm('ipam.delete_ipaddress'): table.columns.show('pk') paginate_table(table, request) @@ -457,10 +456,10 @@ class PrefixIPAddressesView(generic.ObjectView): bulk_querystring = 'vrf_id={}&parent={}'.format(instance.vrf.pk if instance.vrf else '0', instance.prefix) return { - 'first_available_ip': instance.get_first_available_ip(), 'table': table, 'bulk_querystring': bulk_querystring, 'active_tab': 'ip-addresses', + 'first_available_ip': instance.get_first_available_ip(), 'show_available': request.GET.get('show_available', 'true') == 'true', } diff --git a/netbox/netbox/views/generic.py b/netbox/netbox/views/generic.py index b00999b15..aafb2f3d8 100644 --- a/netbox/netbox/views/generic.py +++ b/netbox/netbox/views/generic.py @@ -181,7 +181,6 @@ class ObjectListView(ObjectPermissionRequiredMixin, View): 'table': table, 'permissions': permissions, 'action_buttons': self.action_buttons, - 'table_config_form': TableConfigForm(table=table), 'filter_form': self.filterset_form(request.GET, label_suffix='') if self.filterset_form else None, } context.update(self.extra_context()) diff --git a/netbox/templates/ipam/prefix/ip_addresses.html b/netbox/templates/ipam/prefix/ip_addresses.html index e8c9704bb..0b1fe83b4 100644 --- a/netbox/templates/ipam/prefix/ip_addresses.html +++ b/netbox/templates/ipam/prefix/ip_addresses.html @@ -1,4 +1,6 @@ {% extends 'ipam/prefix/base.html' %} +{% load helpers %} +{% load static %} {% block extra_controls %} {% if perms.ipam.add_ipaddress and active_tab == 'ip-addresses' and first_available_ip %} @@ -11,7 +13,13 @@ {% block content %}
+ {% include 'inc/table_controls.html' with table_modal="IPAddressTable_config" %} {% include 'utilities/obj_table.html' with heading='IP Addresses' bulk_edit_url='ipam:ipaddress_bulk_edit' bulk_delete_url='ipam:ipaddress_bulk_delete' %}
+ {% table_config_form table table_name="IPAddressTable" %} +{% endblock %} + +{% block javascript %} + {% endblock %} diff --git a/netbox/templates/ipam/prefix/ip_ranges.html b/netbox/templates/ipam/prefix/ip_ranges.html index 334cc90b0..18b53d945 100644 --- a/netbox/templates/ipam/prefix/ip_ranges.html +++ b/netbox/templates/ipam/prefix/ip_ranges.html @@ -1,10 +1,17 @@ {% extends 'ipam/prefix/base.html' %} - +{% load helpers %} +{% load static %} {% block content %}
+ {% include 'inc/table_controls.html' with table_modal="IPRangeTable_config" %} {% include 'utilities/obj_table.html' with heading='Child IP Ranges' bulk_edit_url='ipam:prefix_bulk_edit' bulk_delete_url='ipam:prefix_bulk_delete' parent=prefix %}
+ {% table_config_form table table_name="IPRangeTable" %} +{% endblock %} + +{% block javascript %} + {% endblock %} diff --git a/netbox/templates/ipam/prefix/prefixes.html b/netbox/templates/ipam/prefix/prefixes.html index 998b7b70b..6dcbed77d 100644 --- a/netbox/templates/ipam/prefix/prefixes.html +++ b/netbox/templates/ipam/prefix/prefixes.html @@ -2,20 +2,17 @@ {% load helpers %} {% load static %} -{% block buttons %} +{% block extra_controls %} {% include 'ipam/inc/toggle_available.html' %} - {% if request.user.is_authenticated and table_config_form %} - - {% endif %} {% if perms.ipam.add_prefix and active_tab == 'prefixes' and first_available_prefix %} - + Add Child Prefix {% endif %} {% if perms.ipam.add_ipaddress and active_tab == 'ip-addresses' and first_available_ip %} - + - Add an IP Address + Add Child IP Address {% endif %} {{ block.super }} @@ -24,12 +21,13 @@ {% block content %}
+ {% include 'inc/table_controls.html' with table_modal="PrefixDetailTable_config" %} {% include 'utilities/obj_table.html' with heading='Child Prefixes' bulk_edit_url='ipam:prefix_bulk_edit' bulk_delete_url='ipam:prefix_bulk_delete' parent=prefix %}
- {% table_config_form prefix_table table_name="PrefixDetailTable" %} + {% table_config_form table table_name="PrefixDetailTable" %} {% endblock %} {% block javascript %} - + {% endblock %} diff --git a/netbox/templates/utilities/templatetags/table_config_form.html b/netbox/templates/utilities/templatetags/table_config_form.html index 3c44642d4..5e17497e9 100644 --- a/netbox/templates/utilities/templatetags/table_config_form.html +++ b/netbox/templates/utilities/templatetags/table_config_form.html @@ -7,11 +7,11 @@
-
+