예제 #1
0
def internal_link(context, name, text=None, permission=None):
    if permission:
        if permission == 'login_required':
            if not context.request.user.is_authenticated():
                return ''
        else:
            if not context.request.user.has_perm(permission):
                return ''

    return get_internal_link(name, text)
예제 #2
0
def login_link(context):
    if context.request.user.is_authenticated():
        return get_internal_link('logout', 'Logout')
    else:
        return get_internal_link('login', 'Login')
예제 #3
0
def admin_link(context, text='Admin'):
    if not context.request.user.is_superuser:
        return ''

    return get_internal_link('admin:index', text)