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]
|
||||
|
||||
def build_stats():
|
||||
perms = request.user.get_all_permissions()
|
||||
org = (
|
||||
("dcim.view_site", "Sites", Site.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,
|
||||
"disabled": True
|
||||
}
|
||||
if perm in perms:
|
||||
if request.user.has_perm(perm):
|
||||
item["count"] = get_count()
|
||||
item["disabled"] = False
|
||||
items.append(item)
|
||||
|
@ -4,7 +4,6 @@
|
||||
{% load render_table from django_tables2 %}
|
||||
|
||||
{% block header %}
|
||||
{{ block.super }}
|
||||
{% if new_release %}
|
||||
{# new_release is set only if the current user is a superuser or staff member #}
|
||||
<div class="header-alert-container">
|
||||
@ -35,13 +34,22 @@
|
||||
<div class="card-body">
|
||||
<div class="list-group list-group-flush">
|
||||
{% for item in items %}
|
||||
{% if item.count %}
|
||||
<a href="{% url item.url %}" class="list-group-item list-group-item-action{% if item.disabled %} disabled{% endif %}">
|
||||
{% if not item.disabled %}
|
||||
<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">
|
||||
{{ item.label }}
|
||||
<h4 class="mb-1">{{ item.count }}</h4>
|
||||
</div>
|
||||
</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 %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user