mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Added total IPv4/IPv6 counts to ipam.AggregateListView
This commit is contained in:
@ -139,6 +139,21 @@ class AggregateListView(ObjectListView):
|
|||||||
edit_permissions = ['ipam.change_aggregate', 'ipam.delete_aggregate']
|
edit_permissions = ['ipam.change_aggregate', 'ipam.delete_aggregate']
|
||||||
template_name = 'ipam/aggregate_list.html'
|
template_name = 'ipam/aggregate_list.html'
|
||||||
|
|
||||||
|
def extra_context(self):
|
||||||
|
ipv4_total = 0
|
||||||
|
ipv6_total = 0
|
||||||
|
|
||||||
|
for a in self.queryset:
|
||||||
|
if a.prefix.version == 4:
|
||||||
|
ipv4_total += a.prefix.size
|
||||||
|
elif a.prefix.version == 6:
|
||||||
|
ipv6_total += a.prefix.size / 2**64
|
||||||
|
|
||||||
|
return {
|
||||||
|
'ipv4_total': ipv4_total,
|
||||||
|
'ipv6_total': ipv6_total,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def aggregate(request, pk):
|
def aggregate(request, pk):
|
||||||
|
|
||||||
|
@ -57,6 +57,7 @@ INSTALLED_APPS = (
|
|||||||
'django.contrib.sessions',
|
'django.contrib.sessions',
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
|
'django.contrib.humanize',
|
||||||
'debug_toolbar',
|
'debug_toolbar',
|
||||||
'django_extensions',
|
'django_extensions',
|
||||||
'django_tables2',
|
'django_tables2',
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
{% extends '_base.html' %}
|
{% extends '_base.html' %}
|
||||||
|
{% load humanize %}
|
||||||
{% load helpers %}
|
{% load helpers %}
|
||||||
|
|
||||||
{% block title %}Aggregates{% endblock %}
|
{% block title %}Aggregates{% endblock %}
|
||||||
@ -29,6 +30,8 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
{% include 'utilities/obj_table.html' with bulk_edit_url='ipam:aggregate_bulk_edit' bulk_delete_url='ipam:aggregate_bulk_delete' %}
|
{% include 'utilities/obj_table.html' with bulk_edit_url='ipam:aggregate_bulk_edit' bulk_delete_url='ipam:aggregate_bulk_delete' %}
|
||||||
|
<p class="text-right">IPv4 total: <strong>{{ ipv4_total|intcomma }} /32s</strong></p>
|
||||||
|
<p class="text-right">IPv6 total: <strong>{{ ipv6_total|intcomma }} /64s</strong></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
{% include 'inc/filter_panel.html' %}
|
{% include 'inc/filter_panel.html' %}
|
||||||
|
@ -65,15 +65,21 @@ class ObjectListView(View):
|
|||||||
table.base_columns['pk'].visible = True
|
table.base_columns['pk'].visible = True
|
||||||
RequestConfig(request, paginate={'klass': EnhancedPaginator}).configure(table)
|
RequestConfig(request, paginate={'klass': EnhancedPaginator}).configure(table)
|
||||||
|
|
||||||
return render(request, self.template_name, {
|
context = {
|
||||||
'table': table,
|
'table': table,
|
||||||
'filter_form': self.filter_form(request.GET, label_suffix='') if self.filter_form else None,
|
'filter_form': self.filter_form(request.GET, label_suffix='') if self.filter_form else None,
|
||||||
'export_templates': ExportTemplate.objects.filter(content_type=object_ct),
|
'export_templates': ExportTemplate.objects.filter(content_type=object_ct),
|
||||||
})
|
}
|
||||||
|
context.update(self.extra_context())
|
||||||
|
|
||||||
|
return render(request, self.template_name, context)
|
||||||
|
|
||||||
def alter_queryset(self, request):
|
def alter_queryset(self, request):
|
||||||
return self.queryset
|
return self.queryset
|
||||||
|
|
||||||
|
def extra_context(self):
|
||||||
|
return {}
|
||||||
|
|
||||||
|
|
||||||
class ObjectEditView(View):
|
class ObjectEditView(View):
|
||||||
model = None
|
model = None
|
||||||
|
Reference in New Issue
Block a user