• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python menu_pool.apply_modifiers函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中menus.menu_pool.menu_pool.apply_modifiers函数的典型用法代码示例。如果您正苦于以下问题:Python apply_modifiers函数的具体用法?Python apply_modifiers怎么用?Python apply_modifiers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了apply_modifiers函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: get_context

 def get_context(self, context, levels, root_level, nephews, template):
     # Django 1.4 doesn't accept 'None' as a tag value and resolve to ''
     # So we need to force it to None again
     if not root_level and root_level != 0:
         root_level = None
     try:
         # If there's an exception (500), default context_processors may not
         # be called.
         request = context['request']
     except KeyError:
         return {'template': 'menu/empty.html'}
     nodes = menu_pool.get_nodes(request)
     children = []
     # adjust root_level so we cut before the specified level, not after
     include_root = False
     if root_level is not None and root_level > 0:
         root_level -= 1
     elif root_level is not None and root_level == 0:
         include_root = True
     for node in nodes:
         if root_level is None:
             if node.selected:
                 # if no root_level specified, set it to the selected nodes
                 # level
                 root_level = node.level
                 # is this the ancestor of current selected node at the root
                 # level?
         is_root_ancestor = (node.ancestor and node.level == root_level)
         # is a node selected on the root_level specified
         root_selected = (node.selected and node.level == root_level)
         if is_root_ancestor or root_selected:
             cut_after(node, levels, [])
             children = node.children
             for child in children:
                 child.parent = None
                 if child.sibling:
                     cut_after(child, nephews, [])
                     # if root_level was 0 we need to give the menu the
                     # entire tree
                 # not just the children
             if include_root:
                 children = menu_pool.apply_modifiers(
                     [node], request, post_cut=True
                 )
             else:
                 children = menu_pool.apply_modifiers(
                     children, request, post_cut=True
                 )
     context.update({
         'children': children,
         'template': template,
         'from_level': 0,
         'to_level': 0,
         'extra_inactive': 0,
         'extra_active': 0
     })
     return context
开发者ID:Ratnam123,项目名称:WFIMS,代码行数:57,代码来源:fix_menu_tags.py


示例2: _get_nodes

 def _get_nodes(self, path='/'):
     node1 = NavigationNode('1', '/1/', 1)
     node2 = NavigationNode('2', '/2/', 2, 1)
     node3 = NavigationNode('3', '/3/', 3, 2)
     node4 = NavigationNode('4', '/4/', 4, 2)
     node5 = NavigationNode('5', '/5/', 5)
     nodes = [node1, node2, node3, node4, node5]
     tree = _build_nodes_inner_for_one_menu([n for n in nodes], "test")
     request = self.get_request(path)
     menu_pool.apply_modifiers(tree, request)
     return tree, nodes
开发者ID:AdrianRibao,项目名称:django-cms,代码行数:11,代码来源:menu.py


示例3: show_sub_menu

def show_sub_menu(context, levels=100, template="menu/sub_menu.html"):
    """
    show the sub menu of the current nav-node.
    -levels: how many levels deep
    -temlplate: template used to render the navigation
    """
    
    try:
        # If there's an exception (500), default context_processors may not be called.
        request = context['request']
    except KeyError:
        return {'template': 'menu/empty.html'}
    nodes = menu_pool.get_nodes(request)
    children = []
    for node in nodes:
        if node.selected:
            cut_after(node, levels, [])
            children = node.children
            for child in children:
                child.parent = None
            children = menu_pool.apply_modifiers(children, request, post_cut=True)
    context.update({'children':children,
                    'template':template,
                    'from_level':0,
                    'to_level':0,
                    'extra_inactive':0,
                    'extra_active':0
                    })
    return context        
开发者ID:Natim,项目名称:django-cms-2.0,代码行数:29,代码来源:menu_tags.py


示例4: get_context

 def get_context(self, context, levels, template):
     try:
         # If there's an exception (500), default context_processors may not be called.
         request = context["request"]
     except KeyError:
         return {"template": "menu/empty.html"}
     nodes = menu_pool.get_nodes(request)
     children = []
     for node in nodes:
         if node.selected:
             cut_after(node, levels, [])
             children = node.children
             for child in children:
                 child.parent = None
             children = menu_pool.apply_modifiers(children, request, post_cut=True)
     context.update(
         {
             "children": children,
             "template": template,
             "from_level": 0,
             "to_level": 0,
             "extra_inactive": 0,
             "extra_active": 0,
         }
     )
     return context
开发者ID:kewinwang,项目名称:django-cms,代码行数:26,代码来源:menu_tags.py


示例5: _get_context_internal

    def _get_context_internal(self, context, from_level, to_level, extra_inactive,
                    extra_active, max_count, filter_opt, template, namespace, root_id, next_page):
        trim_children = (filter_opt & FILTER_TRIM_CHILDREN != 0)
        try:
            # If there's an exception (500), default context_processors may not be called.
            request = context['request']
        except KeyError:
            return {'template': 'menu/empty.html'}

        has_root_node = False

        if next_page:
            children = next_page.children
        else: 
            #new menu... get all the data so we can save a lot of queries
            nodes = menu_pool.get_nodes(request, namespace, root_id)
            if root_id: # find the root id and cut the nodes
                id_nodes = menu_pool.get_nodes_by_attribute(nodes, "reverse_id", root_id)
                if id_nodes:
                    root_node = node = id_nodes[0]
                    has_root_node = True

                    new_nodes = node.children
                    for n in new_nodes:
                        n.parent = None
                    from_level += node.level + 1
                    to_level += node.level + 1
                else:
                    new_nodes = []
                nodes = new_nodes
            children = cut_levels(nodes, from_level, to_level, extra_inactive, extra_active, trim_children)
            children = menu_pool.apply_modifiers(children, request, namespace, root_id, post_cut=True)

        if filter_opt & FILTER_INTER:
            children = [node for node in children if node.is_leaf_node]
        elif filter_opt & FILTER_LEAF:
            children = [node for node in children if not node.is_leaf_node]

        # only return the top ``max_count`` ones if specified
        if max_count != -1:
            children = children[:max_count]

        try:
            context.update({'children':children,
                            'template':template,
                            'from_level':from_level,
                            'to_level':to_level,
                            'extra_inactive':extra_inactive,
                            'extra_active':extra_active,
                            'max_count':max_count,
                            'filter_opt':filter_opt,
                            'namespace':namespace})
            if has_root_node:
                context['root_node'] = root_node

        except:
            context = {"template":template}
        return context
开发者ID:team-xue,项目名称:xue,代码行数:58,代码来源:menu_tags.py


示例6: _navigation_preview

 def _navigation_preview(self, request, nav_node):
     if not request or not nav_node:
         return ''
     nodes = menu_pool.get_nodes(request, None, None)
     nodes = cut_levels(nodes, 0, 1, 1, 100)
     nodes = menu_pool.apply_modifiers(
         nodes, request, None, None, post_cut=True)
     output = []
     self._get_nodes(request, nodes, nav_node.menu_id, output)
     html_preview = ''.join(output)
     if 'current-node' not in html_preview:
         return ""
     return html_preview
开发者ID:laurafeier,项目名称:django-cms-blogger,代码行数:13,代码来源:admin.py


示例7: show_menu

def show_menu(context, from_level=0, to_level=100, extra_inactive=0, extra_active=100, template="menu/menu.html", namespace=None, root_id=None, next_page=None, ):
    """
    render a nested list of all children of the pages
    - from_level: starting level
    - to_level: max level
    - extra_inactive: how many levels should be rendered of the not active tree?
    - extra_active: how deep should the children of the active node be rendered?
    - namespace: the namespace of the menu. if empty will use all namespaces
    - root_id: the id of the root node
    - template: template used to render the menu

    """
    try:
        # If there's an exception (500), default context_processors may not be called.
        request = context['request']
    except KeyError:
        return {'template': 'menu/empty.html'}
    
    if next_page:
        children = next_page.children
    else: 
        #new menu... get all the data so we can save a lot of queries
        nodes = menu_pool.get_nodes(request, namespace, root_id)
        if root_id: # find the root id and cut the nodes
            id_nodes = menu_pool.get_nodes_by_attribute(nodes, "reverse_id", root_id)
            if id_nodes:
                node = id_nodes[0]
                new_nodes = node.children
                for n in new_nodes:
                    n.parent = None
                from_level += node.level + 1
                to_level += node.level + 1
            else:
                new_nodes = []
            nodes = new_nodes
        children = cut_levels(nodes, from_level, to_level, extra_inactive, extra_active)
        children = menu_pool.apply_modifiers(children, request, namespace, root_id, post_cut=True)
    
    try:
        context.update({'children':children,
                        'template':template,
                        'from_level':from_level,
                        'to_level':to_level,
                        'extra_inactive':extra_inactive,
                        'extra_active':extra_active,
                        'namespace':namespace})
    except:
        context = {"template":template}
    return context
开发者ID:Natim,项目名称:django-cms-2.0,代码行数:49,代码来源:menu_tags.py


示例8: get_context

    def get_context(self, context, from_level, to_level, extra_inactive,
                    extra_active, template, namespace, root_id, next_page):
        try:
            # If there's an exception (500), default context_processors may not be called.
            request = context['request']
        except KeyError:
            return {'template': 'menu/empty.html'}

        if next_page:
            children = next_page.children
        else:
        #new menu... get all the data so we can save a lot of queries
            nodes = menu_pool.get_nodes(request, namespace, root_id)
            if root_id: # find the root id and cut the nodes
                id_nodes = menu_pool.get_nodes_by_attribute(nodes, "reverse_id", root_id)
                if id_nodes:
                    node = id_nodes[0]
                    nodes = node.children
                    for remove_parent in nodes:
                        remove_parent.parent = None
                    from_level += node.level + 1
                    to_level += node.level + 1
                    nodes = flatten(nodes)
                else:
                    nodes = []
            children = cut_levels(nodes, from_level, to_level, extra_inactive, extra_active)
            children = menu_pool.apply_modifiers(children, request, namespace, root_id, post_cut=True)

        try:
            context.update({'children': children,
                'template': template,
                'from_level': from_level,
                'to_level': to_level,
                'extra_inactive': extra_inactive,
                'extra_active': extra_active,
                'namespace': namespace})
        except:
            context = {"template": template}
        return context
开发者ID:11craft,项目名称:django-cms,代码行数:39,代码来源:menu_tags.py



注:本文中的menus.menu_pool.menu_pool.apply_modifiers函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python menu_pool.clear函数代码示例发布时间:2022-05-27
下一篇:
Python menumanager.MenuManager类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap