From 1be748b479f3dc669f09c6cf9f8122c048c6f326 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Fri, 1 Oct 2021 16:21:16 -0400 Subject: [PATCH] Fixes #6433: Fix bulk editing of child prefixes under aggregate view --- docs/release-notes/version-3.0.md | 1 + netbox/ipam/views.py | 1 + netbox/templates/ipam/aggregate.html | 6 +++--- netbox/templates/utilities/obj_table.html | 2 +- netbox/utilities/tables.py | 10 ++++++++++ 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/docs/release-notes/version-3.0.md b/docs/release-notes/version-3.0.md index 7e0198260..9a5862f6c 100644 --- a/docs/release-notes/version-3.0.md +++ b/docs/release-notes/version-3.0.md @@ -11,6 +11,7 @@ ### Bug Fixes +* [#6433](https://github.com/netbox-community/netbox/issues/6433) - Fix bulk editing of child prefixes under aggregate view * [#6895](https://github.com/netbox-community/netbox/issues/6895) - Remove errant markup for null values in CSV export * [#7373](https://github.com/netbox-community/netbox/issues/7373) - Fix flashing when server, client, and browser color-mode preferences are mismatched * [#7397](https://github.com/netbox-community/netbox/issues/7397) - Fix AttributeError exception when rendering export template for devices via REST API diff --git a/netbox/ipam/views.py b/netbox/ipam/views.py index 015d47065..c24a80124 100644 --- a/netbox/ipam/views.py +++ b/netbox/ipam/views.py @@ -240,6 +240,7 @@ class AggregateView(generic.ObjectView): return { 'prefix_table': prefix_table, 'permissions': permissions, + 'bulk_querystring': f'within={instance.prefix}', 'show_available': request.GET.get('show_available', 'true') == 'true', } diff --git a/netbox/templates/ipam/aggregate.html b/netbox/templates/ipam/aggregate.html index 29aeec1ef..c254d9d63 100644 --- a/netbox/templates/ipam/aggregate.html +++ b/netbox/templates/ipam/aggregate.html @@ -75,8 +75,8 @@
-
- {% include 'utilities/obj_table.html' with table=prefix_table heading='Child Prefixes' bulk_edit_url='ipam:prefix_bulk_edit' bulk_delete_url='ipam:prefix_bulk_delete' %} -
+
+ {% include 'utilities/obj_table.html' with table=prefix_table heading='Child Prefixes' bulk_edit_url='ipam:prefix_bulk_edit' bulk_delete_url='ipam:prefix_bulk_delete' %} +
{% endblock %} diff --git a/netbox/templates/utilities/obj_table.html b/netbox/templates/utilities/obj_table.html index 99ab5c0c7..10337ff43 100644 --- a/netbox/templates/utilities/obj_table.html +++ b/netbox/templates/utilities/obj_table.html @@ -24,7 +24,7 @@
diff --git a/netbox/utilities/tables.py b/netbox/utilities/tables.py index 446438b5c..09fb8350c 100644 --- a/netbox/utilities/tables.py +++ b/netbox/utilities/tables.py @@ -111,6 +111,16 @@ class BaseTable(tables.Table): def selected_columns(self): return self._get_columns(visible=True) + @property + def objects_count(self): + """ + Return the total number of real objects represented by the Table. This is useful when dealing with + prefixes/IP addresses/etc., where some table rows may represent available address space. + """ + if not hasattr(self, '_objects_count'): + self._objects_count = sum(1 for obj in self.data if getattr(obj, 'pk')) + return self._objects_count + # # Table columns