Esempio n. 1
0
def admin_tools_render_menu(context, menu=None):
    """
    Template tag that renders the menu, it takes an optional ``Menu`` instance
    as unique argument, if not given, the menu will be retrieved with the
    ``get_admin_menu`` function.
    """
    if menu is None:
        menu = get_admin_menu()

    menu.init_with_context(context)
    has_bookmark_item = False
    bookmark = None
    if len([c for c in menu.children if isinstance(c, items.Bookmarks)]) > 0:
        has_bookmark_item = True
        url = context['request'].get_full_path()
        try:
            bookmark = Bookmark.objects.filter(user=context['request'].user, url=url)[0]
        except:
            pass

    context.update({
        'template': menu.template,
        'menu': menu,
        'media_url': get_media_url(),
        'has_bookmark_item': has_bookmark_item,
        'bookmark': bookmark,
    })
    return context
Esempio n. 2
0
def admin_tools_render_menu(context, menu=None):
    """
    Template tag that renders the menu, it takes an optional ``Menu`` instance
    as unique argument, if not given, the menu will be retrieved with the
    ``get_admin_menu`` function.
    """
    if menu is None:
        menu = get_admin_menu(context)

    menu.init_with_context(context)
    has_bookmark_item = False
    bookmark = None
    if len([c for c in menu.children if isinstance(c, items.Bookmarks)]) > 0:
        has_bookmark_item = True
        url = context['request'].get_full_path()
        try:
            bookmark = Bookmark.objects.filter(user=context['request'].user,
                                               url=url)[0]
        except:
            pass

    context.update({
        'template':
        menu.template,
        'menu':
        menu,
        'has_bookmark_item':
        has_bookmark_item,
        'bookmark':
        bookmark,
        'admin_url':
        reverse('%s:index' % get_admin_site_name(context)),
    })
    return context
Esempio n. 3
0
def admin_tools_render_menu_css(context, menu=None):
    """
    Template tag that renders the menu css files,, it takes an optional 
    ``Menu`` instance as unique argument, if not given, the menu will be
    retrieved with the ``get_admin_menu`` function.
    """
    if menu is None:
        menu = get_admin_menu(context)

    context.update({
        'template': 'admin_tools/menu/css.html',
        'css_files': menu.Media.css,
    })
    return context
def admin_tools_render_menu_css(context, menu=None):
    """
    Template tag that renders the menu css files,, it takes an optional 
    ``Menu`` instance as unique argument, if not given, the menu will be
    retrieved with the ``get_admin_menu`` function.
    """
    if menu is None:
        menu = get_admin_menu(context)

    context.update({
        'template': 'admin_tools/menu/css.html',
        'css_files': menu.Media.css,
    })
    return context