sideabr fixes 7 atemepts in it
This commit is contained in:
@@ -24,19 +24,33 @@ class Igny8AdminSite(UnfoldAdminSite):
|
||||
"""Get admin URLs without custom dashboard"""
|
||||
urls = super().get_urls()
|
||||
return urls
|
||||
|
||||
def each_context(self, request):
|
||||
"""
|
||||
Override context to ensure our custom app_list is always used
|
||||
This is called by all admin templates for sidebar rendering
|
||||
"""
|
||||
context = super().each_context(request)
|
||||
# Force our custom app list to be used everywhere
|
||||
context['available_apps'] = self.get_app_list(request)
|
||||
return context
|
||||
|
||||
def get_app_list(self, request):
|
||||
def get_app_list(self, request, app_label=None):
|
||||
"""
|
||||
Customize the app list to organize models into logical groups
|
||||
NO EMOJIS - Unfold handles all icons via Material Design
|
||||
|
||||
Args:
|
||||
request: The HTTP request
|
||||
app_label: Optional app label to filter (used for app index pages)
|
||||
"""
|
||||
# Get the default app list
|
||||
app_dict = self._build_app_dict(request)
|
||||
app_dict = self._build_app_dict(request, app_label)
|
||||
|
||||
# Define our custom groups with their models (using object_name)
|
||||
# Organized by business function - Material icons configured in Unfold
|
||||
custom_groups = {
|
||||
'Igny8_Core_Auth': {
|
||||
'Accounts & Users': {
|
||||
'models': [
|
||||
('igny8_core_auth', 'Account'),
|
||||
('igny8_core_auth', 'User'),
|
||||
@@ -155,7 +169,8 @@ class Igny8AdminSite(UnfoldAdminSite):
|
||||
},
|
||||
}
|
||||
|
||||
# Build the organized app list
|
||||
# ALWAYS build and return our custom organized app list
|
||||
# regardless of app_label parameter (for consistent sidebar on all pages)
|
||||
organized_apps = []
|
||||
|
||||
for group_name, group_config in custom_groups.items():
|
||||
@@ -171,12 +186,18 @@ class Igny8AdminSite(UnfoldAdminSite):
|
||||
break
|
||||
|
||||
if group_models:
|
||||
# Get the first model's app_label to use as the real app_label
|
||||
first_model_app_label = group_config['models'][0][0]
|
||||
organized_apps.append({
|
||||
'name': group_name,
|
||||
'app_label': group_name.lower().replace(' ', '_').replace('&', 'and'),
|
||||
'app_url': '#',
|
||||
'app_label': first_model_app_label, # Use real app_label, not fake one
|
||||
'app_url': f'/admin/{first_model_app_label}/', # Real URL, not '#'
|
||||
'has_module_perms': True,
|
||||
'models': group_models,
|
||||
})
|
||||
|
||||
return organized_apps
|
||||
|
||||
|
||||
# Instantiate custom admin site
|
||||
admin_site = Igny8AdminSite(name='admin')
|
||||
|
||||
Reference in New Issue
Block a user