def menu_style_check(context, *args, **kwargs):
request = context['request']
active_style = 'menu_active'
display_style = 'hidden'
try:
resolver_match = urlresolvers.resolve(request.path_info)
url_name = resolver_match.url_name
namespaces = resolver_match.namespaces
for arg in args:
tmp_path = '.'.join(namespaces)
if len(tmp_path) > 0:
tmp_path += ':' + url_name
else:
tmp_path = url_name
s = arg.split(':')
if len(s):
temp_url_name = s[-1]
for group in request.user.groups.all():
for staff_permission in group.staffpermission_set.all():
if staff_permission.allowed_url_name == 'all' \
or staff_permission.allowed_url_name == temp_url_name:
display_style = ''
if tmp_path == arg:
return active_style + ' ' + display_style
except:
return display_style
return display_style
评论列表
文章目录