예제 #1
0
def account_processor(request):
    """Provides account information to RequestContext.

    Returns these variables:
     - account: This is the nav.models.profiles.Account object representing the
       current user.
     - is_admin: Does this user belong to the NAV administrator group
     - messages: A list of message dictionaries which is meant for the user to
       see.
    """
    account = get_account(request)
    admin = is_admin(account)
    messages = Messages(request)
    messages = messages.get_and_delete()
    sudo = get_sudoer(request)

    my_links = NavbarLink.objects.filter(account=account)

    tools = sorted(tool_list(account), key=attrgetter('name'))

    current_user_data = {
        'account': account,
        'is_admin': admin,
        'sudoer': sudo,
        'messages': messages,
        'my_links': my_links,
        'tools': tools,
        'split_tools': split_tools(tools)
    }
    return {
        'current_user_data': current_user_data,
    }
예제 #2
0
def account_processor(request):
    """Provides account information to RequestContext.

    Returns these variables:
     - account: This is the nav.models.profiles.Account object representing the
       current user.
     - is_admin: Does this user belong to the NAV administrator group
     - messages: A list of message dictionaries which is meant for the user to
       see.
    """
    account = get_account(request)
    admin = is_admin(account)
    messages = Messages(request)
    messages = messages.get_and_delete()
    sudo = get_sudoer(request)

    my_links = NavbarLink.objects.filter(account=account)

    tools = sorted(tool_list(account), key=attrgetter('name'))

    current_user_data = {
        'account': account,
        'is_admin': admin,
        'sudoer': sudo,
        'messages': messages,
        'my_links': my_links,
        'tools': tools,
        'split_tools': split_tools(tools)
    }
    return {
        'current_user_data': current_user_data,
    }
예제 #3
0
def can_modify_navlet(account, request):
    """Determine if this account can modify navlets"""
    return not (account.is_default_account() and not get_sudoer(request))
예제 #4
0
def can_modify_navlet(account, request):
    """Determine if this account can modify navlets"""
    return not (account.is_default_account() and not get_sudoer(request))