From 6612e0107e59af80d0eb84a84f8086826b0a8dd8 Mon Sep 17 00:00:00 2001 From: Glenn Matthews Date: Fri, 2 Oct 2020 10:40:05 -0400 Subject: [PATCH] Limit main IPAddress view to a max of 10 duplicate addresses. Fixes #5197 --- netbox/ipam/views.py | 4 +++- netbox/templates/ipam/ipaddress.html | 20 +++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/netbox/ipam/views.py b/netbox/ipam/views.py index c3eac0fd7..3fbceee53 100644 --- a/netbox/ipam/views.py +++ b/netbox/ipam/views.py @@ -527,7 +527,8 @@ class IPAddressView(ObjectView): # Exclude anycast IPs if this IP is anycast if ipaddress.role == IPAddressRoleChoices.ROLE_ANYCAST: duplicate_ips = duplicate_ips.exclude(role=IPAddressRoleChoices.ROLE_ANYCAST) - duplicate_ips_table = tables.IPAddressTable(list(duplicate_ips), orderable=False) + # Limit to a maximum of 10 duplicates displayed here + duplicate_ips_table = tables.IPAddressTable(duplicate_ips[:10], orderable=False) # Related IP table related_ips = IPAddress.objects.restrict(request.user, 'view').exclude( @@ -547,6 +548,7 @@ class IPAddressView(ObjectView): 'ipaddress': ipaddress, 'parent_prefixes_table': parent_prefixes_table, 'duplicate_ips_table': duplicate_ips_table, + 'more_duplicate_ips': duplicate_ips.count() > 10, 'related_ips_table': related_ips_table, }) diff --git a/netbox/templates/ipam/ipaddress.html b/netbox/templates/ipam/ipaddress.html index ff83061cf..f213a275a 100644 --- a/netbox/templates/ipam/ipaddress.html +++ b/netbox/templates/ipam/ipaddress.html @@ -3,6 +3,7 @@ {% load custom_links %} {% load helpers %} {% load plugins %} +{% load render_table from django_tables2 %} {% block header %}
@@ -159,7 +160,24 @@
{% include 'panel_table.html' with table=parent_prefixes_table heading='Parent Prefixes' %} {% if duplicate_ips_table.rows %} - {% include 'panel_table.html' with table=duplicate_ips_table heading='Duplicate IP Addresses' panel_class='danger' %} + {# Custom version of panel_table.html #} +
+
+ Duplicate IP Addresses + {% if more_duplicate_ips %} +
+ Show all +
+ {% endif %} +
+ {% render_table duplicate_ips_table 'inc/table.html' %} +
{% endif %} {% include 'utilities/obj_table.html' with table=related_ips_table table_template='panel_table.html' heading='Related IP Addresses' panel_class='default noprint' %} {% plugin_right_page ipaddress %}