ソースを参照

Closes #8494: Include locations count under tenant view

jeremystretch 4 年 前
コミット
8545a547b9

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

@@ -10,6 +10,7 @@
 * [#8381](https://github.com/netbox-community/netbox/issues/8381) - Add contacts to global search function
 * [#8381](https://github.com/netbox-community/netbox/issues/8381) - Add contacts to global search function
 * [#8462](https://github.com/netbox-community/netbox/issues/8462) - Linkify manufacturer column in device type table
 * [#8462](https://github.com/netbox-community/netbox/issues/8462) - Linkify manufacturer column in device type table
 * [#8476](https://github.com/netbox-community/netbox/issues/8476) - Bring the ASN Web UI up to the standard set by other objects
 * [#8476](https://github.com/netbox-community/netbox/issues/8476) - Bring the ASN Web UI up to the standard set by other objects
+* [#8494](https://github.com/netbox-community/netbox/issues/8494) - Include locations count under tenant view
 
 
 ### Bug Fixes
 ### Bug Fixes
 
 

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

@@ -59,6 +59,10 @@
                     <h2><a href="{% url 'dcim:rackreservation_list' %}?tenant_id={{ object.pk }}" class="stat-btn btn {% if stats.rackreservation_count %}btn-primary{% else %}btn-outline-dark{% endif %} btn-lg">{{ stats.rackreservation_count }}</a></h2>
                     <h2><a href="{% url 'dcim:rackreservation_list' %}?tenant_id={{ object.pk }}" class="stat-btn btn {% if stats.rackreservation_count %}btn-primary{% else %}btn-outline-dark{% endif %} btn-lg">{{ stats.rackreservation_count }}</a></h2>
                     <p>Rack reservations</p>
                     <p>Rack reservations</p>
                 </div>
                 </div>
+                <div class="col col-md-4 text-center">
+                    <h2><a href="{% url 'dcim:location_list' %}?tenant_id={{ object.pk }}" class="stat-btn btn {% if stats.location_count %}btn-primary{% else %}btn-outline-dark{% endif %} btn-lg">{{ stats.location_count }}</a></h2>
+                    <p>Locations</p>
+                </div>
                 <div class="col col-md-4 text-center">
                 <div class="col col-md-4 text-center">
                     <h2><a href="{% url 'dcim:device_list' %}?tenant_id={{ object.pk }}" class="stat-btn btn {% if stats.device_count %}btn-primary{% else %}btn-outline-dark{% endif %} btn-lg">{{ stats.device_count }}</a></h2>
                     <h2><a href="{% url 'dcim:device_list' %}?tenant_id={{ object.pk }}" class="stat-btn btn {% if stats.device_count %}btn-primary{% else %}btn-outline-dark{% endif %} btn-lg">{{ stats.device_count }}</a></h2>
                     <p>Devices</p>
                     <p>Devices</p>

+ 2 - 2
netbox/tenancy/views.py

@@ -1,9 +1,8 @@
 from django.contrib.contenttypes.models import ContentType
 from django.contrib.contenttypes.models import ContentType
-from django.http import Http404
 from django.shortcuts import get_object_or_404
 from django.shortcuts import get_object_or_404
 
 
 from circuits.models import Circuit
 from circuits.models import Circuit
-from dcim.models import Site, Rack, Device, RackReservation, Cable
+from dcim.models import Cable, Device, Location, Rack, RackReservation, Site
 from ipam.models import Aggregate, IPAddress, Prefix, VLAN, VRF, ASN
 from ipam.models import Aggregate, IPAddress, Prefix, VLAN, VRF, ASN
 from netbox.views import generic
 from netbox.views import generic
 from utilities.tables import paginate_table
 from utilities.tables import paginate_table
@@ -103,6 +102,7 @@ class TenantView(generic.ObjectView):
             'site_count': Site.objects.restrict(request.user, 'view').filter(tenant=instance).count(),
             'site_count': Site.objects.restrict(request.user, 'view').filter(tenant=instance).count(),
             'rack_count': Rack.objects.restrict(request.user, 'view').filter(tenant=instance).count(),
             'rack_count': Rack.objects.restrict(request.user, 'view').filter(tenant=instance).count(),
             'rackreservation_count': RackReservation.objects.restrict(request.user, 'view').filter(tenant=instance).count(),
             'rackreservation_count': RackReservation.objects.restrict(request.user, 'view').filter(tenant=instance).count(),
+            'location_count': Location.objects.restrict(request.user, 'view').filter(tenant=instance).count(),
             'device_count': Device.objects.restrict(request.user, 'view').filter(tenant=instance).count(),
             'device_count': Device.objects.restrict(request.user, 'view').filter(tenant=instance).count(),
             'vrf_count': VRF.objects.restrict(request.user, 'view').filter(tenant=instance).count(),
             'vrf_count': VRF.objects.restrict(request.user, 'view').filter(tenant=instance).count(),
             'prefix_count': Prefix.objects.restrict(request.user, 'view').filter(tenant=instance).count(),
             'prefix_count': Prefix.objects.restrict(request.user, 'view').filter(tenant=instance).count(),