Skip to content

Commit

Permalink
feat: hide sidebar groups with no items
Browse files Browse the repository at this point in the history
  • Loading branch information
iosifnicolae2 authored Sep 25, 2024
1 parent 149c39b commit 3f652ba
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,19 @@ def generator(request: HttpRequest, extra_context: Optional[Dict[str, Any]] = No

return generator

def get_sidebar_list(self, request: HttpRequest) -> List[Dict[str, Any]]:
super_sidebar_list = super().get_sidebar_list(request)
# Do not display groups which are empty or the items permissions are false
sidebar_list = []
for sidebar in super_sidebar_list:
sidebar_items = sidebar.get("items", [])
sidebar_items = [item for item in sidebar_items if item.get("permission", lambda x: True)(request)]
if sidebar_items:
sidebar_list.append({
**sidebar,
"items": sidebar_items
})
return sidebar_list


superapp_admin_site = SuperAppAdminSite()

0 comments on commit 3f652ba

Please sign in to comment.