mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
#6732: Fix rendering of stats on home page when not authenticated
This commit is contained in:
@ -109,12 +109,13 @@ class HomeView(View):
|
||||
for section_label, section_items in sections:
|
||||
stat = {"label": section_label, "items": []}
|
||||
for perm, item_label, description, get_count in section_items:
|
||||
if perm in perms:
|
||||
app, scope = perm.split(".")
|
||||
url = ":".join((app, scope.replace("view_", "") + "_list"))
|
||||
stat["items"].append(
|
||||
{"label": item_label, "description": description, "count": get_count(), "url": url}
|
||||
)
|
||||
item = {"label": item_label, "description": description, "count": None, "url": url, "disabled": True}
|
||||
if perm in perms:
|
||||
item["count"] = get_count()
|
||||
item["disabled"] = False
|
||||
stat["items"].append(item)
|
||||
stats.append(stat)
|
||||
return stats
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
<div class="card-body">
|
||||
<div class="list-group list-group-flush">
|
||||
{% for item in section.items %}
|
||||
<a href="{% url item.url %}" class="list-group-item list-group-item-action">
|
||||
<a href="{% url item.url %}" class="list-group-item list-group-item-action{% if item.disabled %} disabled{% endif %}">
|
||||
<div class="d-flex w-100 justify-content-between align-items-center">
|
||||
<div class="d-flex flex-column align-items-start">
|
||||
<h6 class="mb-1">{{ item.label }}</h6>
|
||||
@ -21,7 +21,13 @@
|
||||
<small class="mb-1 text-muted">{{ item.description }}</small>
|
||||
{% endif %}
|
||||
</div>
|
||||
<span class="badge bg-secondary rounded-pill">{{ item.count }}</span>
|
||||
<span class="badge bg-secondary rounded-pill">
|
||||
{% if item.count == None %}
|
||||
<i class="mdi mdi-lock"></i>
|
||||
{% else %}
|
||||
{{ item.count }}
|
||||
{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
|
Reference in New Issue
Block a user