Skip to content

Commit 1be748b

Browse files
committed
Fixes #6433: Fix bulk editing of child prefixes under aggregate view
1 parent 376c776 commit 1be748b

File tree

5 files changed

+16
-4
lines changed

5 files changed

+16
-4
lines changed

docs/release-notes/version-3.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
### Bug Fixes
1313

14+
* [#6433](https://github.com/netbox-community/netbox/issues/6433) - Fix bulk editing of child prefixes under aggregate view
1415
* [#6895](https://github.com/netbox-community/netbox/issues/6895) - Remove errant markup for null values in CSV export
1516
* [#7373](https://github.com/netbox-community/netbox/issues/7373) - Fix flashing when server, client, and browser color-mode preferences are mismatched
1617
* [#7397](https://github.com/netbox-community/netbox/issues/7397) - Fix AttributeError exception when rendering export template for devices via REST API

netbox/ipam/views.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ def get_extra_context(self, request, instance):
240240
return {
241241
'prefix_table': prefix_table,
242242
'permissions': permissions,
243+
'bulk_querystring': f'within={instance.prefix}',
243244
'show_available': request.GET.get('show_available', 'true') == 'true',
244245
}
245246

netbox/templates/ipam/aggregate.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ <h5 class="card-header">
7575
</div>
7676
</div>
7777
<div class="row mb-3">
78-
<div class="col col-md-12">
79-
{% 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' %}
80-
</div>
78+
<div class="col col-md-12">
79+
{% 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' %}
80+
</div>
8181
</div>
8282
{% endblock %}

netbox/templates/utilities/obj_table.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<div class="form-check">
2525
<input type="checkbox" id="select-all" name="_all" class="form-check-input" />
2626
<label for="select-all" class="form-check-label">
27-
Select <strong>all {{ table.rows|length }} {{ table.data.verbose_name_plural }}</strong> matching query
27+
Select <strong>all {{ table.objects_count }} {{ table.data.verbose_name_plural }}</strong> matching query
2828
</label>
2929
</div>
3030
</div>

netbox/utilities/tables.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,16 @@ def available_columns(self):
111111
def selected_columns(self):
112112
return self._get_columns(visible=True)
113113

114+
@property
115+
def objects_count(self):
116+
"""
117+
Return the total number of real objects represented by the Table. This is useful when dealing with
118+
prefixes/IP addresses/etc., where some table rows may represent available address space.
119+
"""
120+
if not hasattr(self, '_objects_count'):
121+
self._objects_count = sum(1 for obj in self.data if getattr(obj, 'pk'))
122+
return self._objects_count
123+
114124

115125
#
116126
# Table columns

0 commit comments

Comments
 (0)