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

Closes #6125: Add locations count to home page

jeremystretch 4 лет назад
Родитель
Сommit
6efe54aa88
3 измененных файлов с 14 добавлено и 2 удалено
  1. 1 0
      docs/release-notes/version-2.11.md
  2. 2 1
      netbox/netbox/views/__init__.py
  3. 11 1
      netbox/templates/home.html

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

@@ -6,6 +6,7 @@
 
 
 * [#6097](https://github.com/netbox-community/netbox/issues/6097) - Redirect old slug-based object views
 * [#6097](https://github.com/netbox-community/netbox/issues/6097) - Redirect old slug-based object views
 * [#6109](https://github.com/netbox-community/netbox/issues/6109) - Add device counts to locations table
 * [#6109](https://github.com/netbox-community/netbox/issues/6109) - Add device counts to locations table
+* [#6125](https://github.com/netbox-community/netbox/issues/6125) - Add locations count to home page
 
 
 ### Bug Fixes (from Beta)
 ### Bug Fixes (from Beta)
 
 

+ 2 - 1
netbox/netbox/views/__init__.py

@@ -16,7 +16,7 @@ from packaging import version
 
 
 from circuits.models import Circuit, Provider
 from circuits.models import Circuit, Provider
 from dcim.models import (
 from dcim.models import (
-    Cable, ConsolePort, Device, DeviceType, Interface, PowerPanel, PowerFeed, PowerPort, Rack, Site,
+    Cable, ConsolePort, Device, DeviceType, Interface, Location, PowerPanel, PowerFeed, PowerPort, Rack, Site,
 )
 )
 from extras.choices import JobResultStatusChoices
 from extras.choices import JobResultStatusChoices
 from extras.models import ObjectChange, JobResult
 from extras.models import ObjectChange, JobResult
@@ -56,6 +56,7 @@ class HomeView(View):
 
 
             # Organization
             # Organization
             'site_count': Site.objects.restrict(request.user, 'view').count(),
             'site_count': Site.objects.restrict(request.user, 'view').count(),
+            'location_count': Location.objects.restrict(request.user, 'view').count(),
             'tenant_count': Tenant.objects.restrict(request.user, 'view').count(),
             'tenant_count': Tenant.objects.restrict(request.user, 'view').count(),
 
 
             # DCIM
             # DCIM

+ 11 - 1
netbox/templates/home.html

@@ -31,7 +31,17 @@
                         <span class="badge pull-right"><i class="mdi mdi-lock"></i></span>
                         <span class="badge pull-right"><i class="mdi mdi-lock"></i></span>
                         <h4 class="list-group-item-heading">Sites</h4>
                         <h4 class="list-group-item-heading">Sites</h4>
                     {% endif %}
                     {% endif %}
-                    <p class="list-group-item-text text-muted">Geographic locations</p>
+                    <p class="list-group-item-text text-muted">Discrete points of presence</p>
+                </div>
+                <div class="list-group-item">
+                    {% if perms.dcim.view_location %}
+                        <span class="badge pull-right">{{ stats.location_count }}</span>
+                        <h4 class="list-group-item-heading"><a href="{% url 'dcim:location_list' %}">Locations</a></h4>
+                    {% else %}
+                        <span class="badge pull-right"><i class="mdi mdi-lock"></i></span>
+                        <h4 class="list-group-item-heading">Locations</h4>
+                    {% endif %}
+                    <p class="list-group-item-text text-muted">Locations within sites</p>
                 </div>
                 </div>
                 <div class="list-group-item">
                 <div class="list-group-item">
                     {% if perms.tenancy.view_tenant %}
                     {% if perms.tenancy.view_tenant %}