mark active menu item as active
This commit is contained in:
parent
210d1e122c
commit
81b9bc163b
3 changed files with 31 additions and 3 deletions
|
@ -4,8 +4,13 @@ This module provides context processor implementations for gnuviechadmin.
|
|||
"""
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
||||
def navigation(request):
|
||||
"""
|
||||
|
@ -24,4 +29,25 @@ def navigation(request):
|
|||
'phppgadmin_url': settings.GVA_LINK_PHPPGADMIN,
|
||||
'active_item': 'dashboard',
|
||||
}
|
||||
if request.resolver_match:
|
||||
viewfunc = request.resolver_match.func
|
||||
viewmodule = viewfunc.__module__
|
||||
if viewmodule == 'contact.views':
|
||||
context['active_item'] = 'contact'
|
||||
elif viewmodule == 'about.views':
|
||||
context['active_item'] = 'about'
|
||||
elif viewmodule in (
|
||||
'hostingpackages.views', 'osusers.views', 'userdbs.views',
|
||||
'managemails.views', 'websites.views', 'domains.views',
|
||||
):
|
||||
context['active_item'] = 'hostingpackage'
|
||||
elif viewmodule in (
|
||||
'allauth.account.views', 'allauth.socialaccount.views'
|
||||
):
|
||||
context['active_item'] = 'account'
|
||||
else:
|
||||
_LOGGER.debug(
|
||||
'no special handling for view %s in module %s, fallback to '
|
||||
'default active menu item %s',
|
||||
viewfunc.__name__, viewmodule, context['active_item'])
|
||||
return context
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue