Пример #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 test_tools_should_be_split_in_3_columns():
    icon = ''
    description = ''
    tools = [
        Tool('one', '/one', icon, description),
        Tool('two', '/two', icon, description),
        Tool('three', '/three', icon, description),
        Tool('four', '/four', icon, description),
    ]
    split = split_tools(tools, parts=3)
    assert len(split) == 3