From 03a101471485ef5e5d2bae7f90239e734ef92a38 Mon Sep 17 00:00:00 2001 From: checktheroads Date: Fri, 7 May 2021 11:55:46 -0700 Subject: [PATCH] #6732: Fix rendering of stats on home page when not authenticated --- netbox/netbox/views/__init__.py | 11 ++++++----- netbox/templates/home.html | 10 ++++++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/netbox/netbox/views/__init__.py b/netbox/netbox/views/__init__.py index bc1a68569..66f66cf52 100644 --- a/netbox/netbox/views/__init__.py +++ b/netbox/netbox/views/__init__.py @@ -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: + app, scope = perm.split(".") + url = ":".join((app, scope.replace("view_", "") + "_list")) + item = {"label": item_label, "description": description, "count": None, "url": url, "disabled": True} 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["count"] = get_count() + item["disabled"] = False + stat["items"].append(item) stats.append(stat) return stats diff --git a/netbox/templates/home.html b/netbox/templates/home.html index 40d0f8c7e..c77e241ef 100644 --- a/netbox/templates/home.html +++ b/netbox/templates/home.html @@ -13,7 +13,7 @@