Просмотр исходного кода

Fixes #8476: Bring the ASN Web UI up to the standard set by other objects

Johannes Erwerle 4 лет назад
Родитель
Сommit
8df382d976

+ 1 - 0
docs/release-notes/version-3.1.md

@@ -8,6 +8,7 @@
 * [#8367](https://github.com/netbox-community/netbox/issues/8367) - Add ASNs to global search function
 * [#8368](https://github.com/netbox-community/netbox/issues/8368) - Enable controlling the order of custom script form fields with `field_order`
 * [#8381](https://github.com/netbox-community/netbox/issues/8381) - Add contacts to global search function
+* [#8476](https://github.com/netbox-community/netbox/issues/8476) - Bring the ASN Web UI up to the standard set by other objects
 
 ### Bug Fixes
 

+ 7 - 2
netbox/ipam/tables/ip.py

@@ -119,15 +119,20 @@ class ASNTable(BaseTable):
         url_params={'asn_id': 'pk'},
         verbose_name='Sites'
     )
+    tenant = TenantColumn()
+    tags = TagColumn(
+        url_name='ipam:asn_list'
+    )
+
     actions = ButtonsColumn(ASN)
 
     class Meta(BaseTable.Meta):
         model = ASN
         fields = (
             'pk', 'asn', 'asn_asdot', 'rir', 'site_count', 'tenant', 'description', 'actions', 'created',
-            'last_updated',
+            'last_updated', 'tags',
         )
-        default_columns = ('pk', 'asn', 'rir', 'site_count', 'sites', 'tenant', 'actions')
+        default_columns = ('pk', 'asn', 'rir', 'site_count', 'sites', 'description', 'tenant', 'actions')
 
 
 #

+ 4 - 0
netbox/templates/tenancy/tenant.html

@@ -71,6 +71,10 @@
                     <h2><a href="{% url 'ipam:aggregate_list' %}?tenant_id={{ object.pk }}" class="stat-btn btn {% if stats.aggregate_count %}btn-primary{% else %}btn-outline-dark{% endif %} btn-lg">{{ stats.aggregate_count }}</a></h2>
                     <p>Aggregates</p>
                 </div>
+                <div class="col col-md-4 text-center">
+                    <h2><a href="{% url 'ipam:asn_list' %}?tenant_id={{ object.pk }}" class="stat-btn btn {% if stats.asn_count %}btn-primary{% else %}btn-outline-dark{% endif %} btn-lg">{{ stats.asn_count }}</a></h2>
+                    <p>ASNs</p>
+                </div>
                 <div class="col col-md-4 text-center">
                     <h2><a href="{% url 'ipam:prefix_list' %}?tenant_id={{ object.pk }}" class="stat-btn btn {% if stats.prefix_count %}btn-primary{% else %}btn-outline-dark{% endif %} btn-lg">{{ stats.prefix_count }}</a></h2>
                     <p>Prefixes</p>

+ 2 - 1
netbox/tenancy/views.py

@@ -4,7 +4,7 @@ from django.shortcuts import get_object_or_404
 
 from circuits.models import Circuit
 from dcim.models import Site, Rack, Device, RackReservation, Cable
-from ipam.models import Aggregate, IPAddress, Prefix, VLAN, VRF
+from ipam.models import Aggregate, IPAddress, Prefix, VLAN, VRF, ASN
 from netbox.views import generic
 from utilities.tables import paginate_table
 from utilities.utils import count_related
@@ -113,6 +113,7 @@ class TenantView(generic.ObjectView):
             'virtualmachine_count': VirtualMachine.objects.restrict(request.user, 'view').filter(tenant=instance).count(),
             'cluster_count': Cluster.objects.restrict(request.user, 'view').filter(tenant=instance).count(),
             'cable_count': Cable.objects.restrict(request.user, 'view').filter(tenant=instance).count(),
+            'asn_count': ASN.objects.restrict(request.user, 'view').filter(tenant=instance).count(),
         }
 
         return {