mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Clean up home view stats
This commit is contained in:
@ -56,7 +56,6 @@ class HomeView(View):
|
|||||||
).defer('data')[:10]
|
).defer('data')[:10]
|
||||||
|
|
||||||
def build_stats():
|
def build_stats():
|
||||||
perms = request.user.get_all_permissions()
|
|
||||||
org = (
|
org = (
|
||||||
("dcim.view_site", "Sites", Site.objects.restrict(request.user, 'view').count),
|
("dcim.view_site", "Sites", Site.objects.restrict(request.user, 'view').count),
|
||||||
("tenancy.view_tenant", "Tenants", Tenant.objects.restrict(request.user, 'view').count),
|
("tenancy.view_tenant", "Tenants", Tenant.objects.restrict(request.user, 'view').count),
|
||||||
@ -116,7 +115,7 @@ class HomeView(View):
|
|||||||
"url": url,
|
"url": url,
|
||||||
"disabled": True
|
"disabled": True
|
||||||
}
|
}
|
||||||
if perm in perms:
|
if request.user.has_perm(perm):
|
||||||
item["count"] = get_count()
|
item["count"] = get_count()
|
||||||
item["disabled"] = False
|
item["disabled"] = False
|
||||||
items.append(item)
|
items.append(item)
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
{% load render_table from django_tables2 %}
|
{% load render_table from django_tables2 %}
|
||||||
|
|
||||||
{% block header %}
|
{% block header %}
|
||||||
{{ block.super }}
|
|
||||||
{% if new_release %}
|
{% if new_release %}
|
||||||
{# new_release is set only if the current user is a superuser or staff member #}
|
{# new_release is set only if the current user is a superuser or staff member #}
|
||||||
<div class="header-alert-container">
|
<div class="header-alert-container">
|
||||||
@ -35,13 +34,22 @@
|
|||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="list-group list-group-flush">
|
<div class="list-group list-group-flush">
|
||||||
{% for item in items %}
|
{% for item in items %}
|
||||||
{% if item.count %}
|
{% if not item.disabled %}
|
||||||
<a href="{% url item.url %}" class="list-group-item list-group-item-action{% if item.disabled %} disabled{% endif %}">
|
<a href="{% url item.url %}" class="list-group-item list-group-item-action">
|
||||||
<div class="d-flex w-100 justify-content-between align-items-center">
|
<div class="d-flex w-100 justify-content-between align-items-center">
|
||||||
{{ item.label }}
|
{{ item.label }}
|
||||||
<h4 class="mb-1">{{ item.count }}</h4>
|
<h4 class="mb-1">{{ item.count }}</h4>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
{% else %}
|
||||||
|
<li class="list-group-item list-group-item-action disabled">
|
||||||
|
<div class="d-flex w-100 justify-content-between align-items-center">
|
||||||
|
{{ item.label }}
|
||||||
|
<h4 class="mb-1">
|
||||||
|
<i title="No permission" class="mdi mdi-lock"></i>
|
||||||
|
</h4>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user