custom_tags.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:Server 作者: malaonline 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号