From 23f8a56e94ba9d8d389dd54dd77c4f20deb31413 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 22 Sep 2017 21:17:46 -0400 Subject: [PATCH] Closes #1499: Added utilization graph to child prefixes table --- netbox/ipam/tables.py | 10 +++++----- netbox/ipam/views.py | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/netbox/ipam/tables.py b/netbox/ipam/tables.py index 512b75649..24bb9b3c2 100644 --- a/netbox/ipam/tables.py +++ b/netbox/ipam/tables.py @@ -34,7 +34,7 @@ RIR_ACTIONS = """ UTILIZATION_GRAPH = """ {% load helpers %} -{% if record.pk %}{% utilization_graph value %}{% else %}—{% endif %} +{% if record.pk %}{% utilization_graph record.get_utilization %}{% else %}—{% endif %} """ ROLE_ACTIONS = """ @@ -210,10 +210,10 @@ class AggregateTable(BaseTable): class AggregateDetailTable(AggregateTable): child_count = tables.Column(verbose_name='Prefixes') - get_utilization = tables.TemplateColumn(UTILIZATION_GRAPH, orderable=False, verbose_name='Utilization') + utilization = tables.TemplateColumn(UTILIZATION_GRAPH, orderable=False, verbose_name='Utilization') class Meta(AggregateTable.Meta): - fields = ('pk', 'prefix', 'rir', 'child_count', 'get_utilization', 'date_added', 'description') + fields = ('pk', 'prefix', 'rir', 'child_count', 'utilization', 'date_added', 'description') # @@ -256,10 +256,10 @@ class PrefixTable(BaseTable): class PrefixDetailTable(PrefixTable): - get_utilization = tables.TemplateColumn(UTILIZATION_GRAPH, orderable=False, verbose_name='Utilization') + utilization = tables.TemplateColumn(UTILIZATION_GRAPH, orderable=False) class Meta(PrefixTable.Meta): - fields = ('pk', 'prefix', 'status', 'vrf', 'get_utilization', 'tenant', 'site', 'vlan', 'role', 'description') + fields = ('pk', 'prefix', 'status', 'vrf', 'utilization', 'tenant', 'site', 'vlan', 'role', 'description') # diff --git a/netbox/ipam/views.py b/netbox/ipam/views.py index d0225e567..89eecd352 100644 --- a/netbox/ipam/views.py +++ b/netbox/ipam/views.py @@ -473,11 +473,11 @@ class PrefixView(View): child_prefixes = Prefix.objects.filter( vrf=prefix.vrf, prefix__net_contained=str(prefix.prefix) ).select_related( - 'site', 'role' + 'site', 'vlan', 'role', ).annotate_depth(limit=0) if child_prefixes: child_prefixes = add_available_prefixes(prefix.prefix, child_prefixes) - child_prefix_table = tables.PrefixTable(child_prefixes) + child_prefix_table = tables.PrefixDetailTable(child_prefixes) if request.user.has_perm('ipam.change_prefix') or request.user.has_perm('ipam.delete_prefix'): child_prefix_table.base_columns['pk'].visible = True