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

Python menu_pool.register_modifier函数代码示例

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

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



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

示例1: setUp

    def setUp(self):
        self.simple_user = User.objects.create(username='simple_user', email='[email protected]',
                                               password='simple_user')
        self.advanced_user = User.objects.create(username='advanced_user', email='[email protected]',
                                                 password='advanced_user')
        self.superuser = User.objects.create(username='super_user', email='[email protected]',
                                             password='super_user', is_superuser=True)
        self.advanced_group = Group.objects.create(name='advanced_group')
        self.advanced_group.user_set.add(self.advanced_user)

        page_defaults = {
            'template': 'menu_test.html',
            'language': 'en-us',
        }
        with self.settings(CMS_PERMISSION=False):
            self.p1 = create_page('P1', published=True, in_navigation=True, **page_defaults)
            self.p2 = create_page('P2', published=True, in_navigation=True, parent=self.p1, **page_defaults)
            self.p3 = create_page('P3', published=True, in_navigation=True, parent=self.p2, **page_defaults)

            self.p4 = create_page('P4', published=True, in_navigation=True, **page_defaults)
            self.p5 = create_page('P5', published=True, in_navigation=True, parent=self.p4, **page_defaults)

            self.p6 = create_page('P6', published=True, in_navigation=False, **page_defaults)
            self.p7 = create_page('P7', published=True, in_navigation=True, parent=self.p6, **page_defaults)
            self.p8 = create_page('P8', published=True, in_navigation=True, parent=self.p6, **page_defaults)

        p1_action = CMSAction.objects.create(name='p1_action', page=self.p1.publisher_public)
        p1_action.users.add(self.simple_user)
        p1_action.groups.add(self.advanced_group)

        p2_action = CMSAction.objects.create(name='p2_action', page=self.p2.publisher_public)
        p2_action.users.add(self.simple_user)

        p3_action = CMSAction.objects.create(name='p3_action', page=self.p3.publisher_public)

        p4_action = CMSAction.objects.create(name='p4_action', page=self.p4.publisher_public)
        p4_action.users.add(self.simple_user)
        p4_action.groups.add(self.advanced_group)

        p5_action = CMSAction.objects.create(name='p5_action', page=self.p5.publisher_public)
        p5_action.groups.add(self.advanced_group)

        p6_action = CMSAction.objects.create(name='p6_action', page=self.p6.publisher_public)
        p6_action.groups.add(self.advanced_group)

        p7_action = CMSAction.objects.create(name='p7_action', page=self.p7.publisher_public)
        p7_action.users.add(self.simple_user)

        p8_action = CMSAction.objects.create(name='p8_action', page=self.p8.publisher_public)
        p8_action.groups.add(self.advanced_group)

        menu_pool.register_modifier(ACLModifier)
开发者ID:dwatkinsweb,项目名称:django-acl,代码行数:52,代码来源:tests.py


示例2: register

def register():
    menu_pool.register_modifier(Marker)
    menu_pool.register_modifier(AuthVisibility)
    menu_pool.register_modifier(Level)
    if settings.CMS_GROUPS_RESTRICTED \
                        and settings.CMS_GROUPS_RESTRICTED_NAVIGATION:
        menu_pool.register_modifier(GroupVisibility)
开发者ID:mayh90,项目名称:django-cms,代码行数:7,代码来源:modifiers.py


示例3: reverse

        nodes = []
        nodes.append(NavigationNode(_('Tags'), reverse('objectapp_tag_list'),
                                    'tags'))
        for tag in tags_published():
            nodes.append(NavigationNode(tag.name,
                                        reverse('objectapp_tag_detail',
                                                args=[tag.name]),
                                        tag.pk, 'tags'))
        return nodes


class GbobjectModifier(Modifier):
    """Menu Modifier for gbobjects,
    hide the MenuGbobject in navigation, not in breadcrumbs"""

    def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
        """Modify nodes of a menu"""
        if breadcrumb:
            return nodes
        for node in nodes:
            if node.attr.get('hidden'):
                nodes.remove(node)
        return nodes


menu_pool.register_menu(GbobjectMenu)
menu_pool.register_menu(ObjecttypeMenu)
menu_pool.register_menu(AuthorMenu)
menu_pool.register_menu(TagMenu)
menu_pool.register_modifier(GbobjectModifier)
开发者ID:Big-Data,项目名称:gnowsys-studio,代码行数:30,代码来源:menu.py


示例4: modify

    Then attempt to set icons referenced to page id.
    """
    def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
        # import ipdb; ipdb.set_trace()
        # if post_cut:
        #     return nodes
        # if breadcrumb:
        #     return nodes
        for node in nodes:
            try:
                # Load Menu Icons into template tags
                if __version__ >= "2.4" and __version__ < "3":  # tested with django-cms at version 2.4.3
                    # Load Menu Icons into template tags
                    # Workaround due to the double publishing feature added in 2.4.
                    # menu icons refers to page marked as "publisher_is_draft"
                    
                    node_page = Page.objects.get( id = node.id )
                    draft_page_id = node_page.id if node_page.publisher_is_draft else node_page.publisher_public_id
                    menu_icons = MenuIcon.objects.get( page = draft_page_id )
                else:
                    menu_icons = MenuIcon.objects.get(page=(node.id))
                node.menu_icon_image = menu_icons.menu_icon_image
                node.menu_icon_url = menu_icons.menu_icon_url
                node.menu_icon_font_awesome = menu_icons.menu_icon_font_awesome
            except:
                pass

        return nodes

menu_pool.register_modifier(MenuIconsMod)
开发者ID:beardbig,项目名称:django-theherk-menu-icons,代码行数:30,代码来源:menu.py


示例5: len

        insert_at = position if position < len(nodes) else len(nodes) - 1
        for node in nodes:
           # Discover nodes in the explore menu and separate them
           if node.id == id:
               matched_node = node
               matched_children.append(node)
           elif matched_node in node.get_ancestors():
	           matched_children.append(node)
           else:
               modified_nodes.append(node)

        # Add the explore nodes back at the specified position
        for node in matched_children:
            modified_nodes.insert(insert_at, node)
            insert_at += 1

        return modified_nodes

    def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
        if post_cut:
            return nodes

        modified_nodes = self.move_node(nodes, 'explore', 
            plugin_settings.STORYBASE_EXPLORE_MENU_POSITION)
        modified_nodes = self.move_node(modified_nodes, 'build',
            plugin_settings.STORYBASE_BUILD_MENU_POSITION)

        return modified_nodes

menu_pool.register_modifier(OrderMenuNodes)
开发者ID:jwirfs-brock,项目名称:atlas,代码行数:30,代码来源:menu.py


示例6: hasattr

                            if node.attr.get("is_home", False) and not node.visible:
                                extnode.parent_id = None
                                extnode.parent_namespace = None
                                extnode.parent = None
                            else:
                                extnode.parent_id = node.id
                                extnode.parent_namespace = node.namespace
                                extnode.parent = node
                                node.children.append(extnode)
        removed = []
        # find all not assigned nodes
        for menu in menu_pool.menus.items():
            if hasattr(menu[1], 'cms_enabled') and menu[1].cms_enabled and not menu[0] in exts:
                for node in nodes:
                    if node.namespace == menu[0]:
                        removed.append(node)
        if breadcrumb:  
            # if breadcrumb and home not in navigation add node
            if breadcrumb and home and not home.visible:
                home.visible = True
                if request.path == home.get_absolute_url():
                    home.selected = True
                else:
                    home.selected = False
        # remove all nodes that are nav_extenders and not assigned 
        for node in removed:
            nodes.remove(node)
        return nodes   
menu_pool.register_modifier(NavExtender)

开发者ID:sandeep1988,项目名称:django-taimi-project,代码行数:29,代码来源:menu.py


示例7: SoftRootCutter

                for node in nodes:
                    if node.namespace == menu[0]:
                        removed.append(node)
        if breadcrumb:  
            # if breadcrumb and home not in navigation add node
            if breadcrumb and home and not home.visible:
                home.visible = True
                if request.path == home.get_absolute_url():
                    home.selected = True
                else:
                    home.selected = False
        # remove all nodes that are nav_extenders and not assigned 
        for node in removed:
            nodes.remove(node)
        return nodes   
menu_pool.register_modifier(NavExtender)


class SoftRootCutter(Modifier):
    """
    If anyone understands this, PLEASE write a meaningful description here!
    """
    def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
        # only apply this modifier if we're pre-cut (since what we do is cut)
        if post_cut or not settings.CMS_SOFTROOT:
            return nodes
        selected = None
        root_nodes = []
        # find the selected node as well as all the root nodes
        for node in nodes:
            if node.selected:
开发者ID:wiremine,项目名称:django-cms,代码行数:31,代码来源:menu.py


示例8: objects

from cms.cms_menus import CMSMenu
from cms.models import Page
from menus.base import Modifier
from menus.menu_pool import menu_pool

# Menu nodes which represent real CMS Page objects (vs. some node
# synthesized by a CMS app, such as a "page" for items in a FAQ
# category) have this namespace.
CMS_PAGE_NODE_NAMESPACE = CMSMenu.__name__


class AddIconNameExtension(Modifier):
    """Make the IconNameExtension available in the menu."""

    def _modify_nodes(self, nodes):
        for node in nodes:
            if node.namespace == CMS_PAGE_NODE_NAMESPACE:
                page = Page.objects.get(pk=node.id)
                if getattr(page, 'iconnameextension', None):
                    setattr(node, 'iconnameextension', page.iconnameextension)
                self._modify_nodes(node.children)

    def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
        if post_cut and not breadcrumb:
            self._modify_nodes(nodes)
        return nodes


menu_pool.register_modifier(AddIconNameExtension)
开发者ID:dpenezic,项目名称:ServiceInfo,代码行数:29,代码来源:cms_menus.py


示例9: NewsCleaner

                    pub.strftime('year_%Y_month_%m_day_%d')))

        return nodes

menu_pool.register_menu(NewsyMenu)

class NewsCleaner(Modifier):
    def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
        if post_cut or breadcrumb:
            return nodes

        tags = 0

        filter_dates = re.compile(r'^year_\d{4}_month_\d{1,2}(_day_\d{1,2})?$')

        for node in nodes:
            if node.namespace != 'NewsyMenu':
                continue
            if node.parent_id == 'tags':
                tags += 1
                if tags > 5:
                    node.visible = False
                continue
            if filter_dates.match(str(node.parent_id)):
                node.visible = False

        return nodes

menu_pool.register_modifier(NewsCleaner)

开发者ID:TAMUArch,项目名称:cmsplugin-newsy,代码行数:29,代码来源:menu.py


示例10: resolve

                """
                if self.in_blog_menu_tree(node):
                    func, args, kwargs = resolve(request.path)
                    if self.is_blog_entry(kwargs): 
                        """
                        Then try to match the blog category nav node
                        with the the primary category of the blog entry
                        """
                        entry_categories = kwargs['queryset'][0].categories.all()
                        if len(entry_categories) > 0:
                            primary_category = entry_categories[0]
                            if node.title.lower() == primary_category.slug.lower():
                                node.selected = True
                        else:
                            if self.is_top_level_blog_node(node):
                                node.selected = True
                    else:
                        if 'categories' not in request.path \
                            and self.is_top_level_blog_node(node):
                            """
                            If they're looking at a tag, author or some other blog
                            related thing that is not part of blog sub navigation 
                            bar and is not an entry just make sure 'blog' lights up
                            """
                            node.selected = True

        return nodes

menu_pool.register_menu(FlatBlogCategoryMenu)
menu_pool.register_modifier(FlatBlogCategoryModifier)
开发者ID:andy071001,项目名称:efo-on-django-cms,代码行数:30,代码来源:menu.py


示例11: FollowModifier

menu_pool.register_menu(NewsMenu)


class FollowModifier(Modifier):
    def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
        if not post_cut:
            return nodes

        appNodes = [node for node in nodes if 'targetIndex' in node.attr]
        cmsNodes = [node for node in nodes if not 'targetIndex' in node.attr]

        resultNodes = []

        appNodeIndex = 0
        cmsNodeIndex = 0
        for resultNodeIndex in range(len(nodes)):
            if appNodeIndex < len(appNodes) and appNodes[appNodeIndex].attr['targetIndex'] == resultNodeIndex:
                resultNodes.append(appNodes[appNodeIndex])
                appNodeIndex += 1
            elif cmsNodeIndex < len(cmsNodes):
                resultNodes.append(cmsNodes[cmsNodeIndex])
                cmsNodeIndex += 1
            else:
                raise Exception('Error merging app menu and cms menu items')

        return resultNodes


menu_pool.register_modifier(FollowModifier)
开发者ID:JHei,项目名称:cmsplugin_simplenews,代码行数:29,代码来源:menu.py


示例12: TheselectionMode

from menus.base import Modifier
from menus.menu_pool import menu_pool

from cms.models import Page


class TheselectionMode(Modifier):
    """

    """

    def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
        extension = Page.theselectionextension
        for node in nodes:
            try:
                page = Page.objects.get(pk=node.id)
                extensions = page.theselectionextension
                node.subtitle = extensions.subtitle
                node.backgroundcolor = extensions.backgroundcolor
            except:
                pass
        return nodes


menu_pool.register_modifier(TheselectionMode)
开发者ID:thelabeljoyves,项目名称:theselection,代码行数:25,代码来源:cms_menus.py


示例13: reverse

        nodes = []
        nodes.append(NavigationNode(_('Tags'), reverse('gstudio_tag_list'),
                                    'tags'))
        for tag in tags_published():
            nodes.append(NavigationNode(tag.name,
                                        reverse('gstudio_tag_detail',
                                                args=[tag.name]),
                                        tag.pk, 'tags'))
        return nodes


class ObjecttypeModifier(Modifier):
    """Menu Modifier for objecttypes,
    hide the MenuObjecttype in navigation, not in breadcrumbs"""

    def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
        """Modify nodes of a menu"""
        if breadcrumb:
            return nodes
        for node in nodes:
            if node.attr.get('hidden'):
                nodes.remove(node)
        return nodes


menu_pool.register_menu(ObjecttypeMenu)
menu_pool.register_menu(MetatypeMenu)
menu_pool.register_menu(AuthorMenu)
menu_pool.register_menu(TagMenu)
menu_pool.register_modifier(ObjecttypeModifier)
开发者ID:nishant1,项目名称:django-gstudio,代码行数:30,代码来源:menu.py


示例14: next

                root_page = visible_roots.get(root_blog_node.position)
                if root_page:
                    # insert at exact position
                    position_in_nodes = nodes_with_position[root_page]
                elif last_node:
                    # insert after last visible
                    position_in_nodes = nodes_with_position[last_node] + 1

                nodes.insert(position_in_nodes, blog_nav_node)
                new_nodes.append(blog_nav_node)

        # add all blog nodes that are children of other blog nodes
        for b_id in parents_with_children.keys():
            parent_blog_node = next(
                ifilter(lambda n: n.id == b_id, new_nodes), None)
            if not parent_blog_node:
                continue

            for blog_node in parents_with_children.pop(parent_blog_node.id):
                blog_nav_node = _make_navigation_node(
                    blog_node, parent_blog_node, proxy_prefix, node_visible)
                parent_blog_node.children.insert(
                    blog_node.position, blog_nav_node)
                new_nodes.append(blog_nav_node)

        menu_pool._mark_selected(request, new_nodes)
        return nodes


menu_pool.register_modifier(BlogNavigationExtender)
开发者ID:pbs,项目名称:django-cms-blogger,代码行数:30,代码来源:menu.py


示例15: MenuPost

from contents.models import Post
from menus.base import Modifier
from menus.menu_pool import menu_pool


class MenuPost(Modifier):
    def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
        if post_cut:
            return nodes
        for node in nodes:
            node.attr['posts'] = Post.objects.language().filter(translations__active=True, pages_id=node.id).order_by('-date').distinct()
        return nodes

menu_pool.register_modifier(MenuPost)
开发者ID:od-5,项目名称:savann,代码行数:14,代码来源:menu.py


示例16: GlobalMenuModifier

from menus.base import Modifier
from menus.menu_pool import menu_pool

class GlobalMenuModifier(Modifier):
    """
    If the user is logged in, remove certain menu options.
    
    Django cms provides a way to hide an option from a non logged in user, but no
    way to hide something from someone who is logged in. This menu modifier adds
    this capability.
    """
    
    def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
        # We don't modify the breadcrumb, and we also wait until the post_cut
        # phase so that we process a potentially smaller node tree.
        # See http://www.3lance.lv/django-cms/app_integration.html        
        if breadcrumb or not post_cut or not request.user.is_authenticated():
            return nodes
                
        trim_nodes = ['/login/', '/register/']
        
        return filter(lambda node: node.url not in trim_nodes, nodes)
    
menu_pool.register_modifier(GlobalMenuModifier)
开发者ID:andy071001,项目名称:efo-on-django-cms,代码行数:24,代码来源:menu.py


示例17: getattr

            # in case `menu_structure` is not present in config
            return nodes
        if post_cut:
            return nodes
        current_post = getattr(request, get_setting('CURRENT_POST_IDENTIFIER'), None)
        category = None
        if current_post and current_post.__class__ == Post:
            category = current_post.categories.first()
        if not category:
            return nodes

        for node in nodes:
            if '{0}-{1}'.format(category.__class__.__name__, category.pk) == node.id:
                node.selected = True
        return nodes


menu_pool.register_modifier(BlogNavModifier)
menu_pool.register_menu(BlogCategoryMenu)


def clear_menu_cache(**kwargs):
    """
    Empty menu cache when saving categories
    """
    menu_pool.clear(all=True)


post_save.connect(clear_menu_cache, sender=BlogCategory)
post_delete.connect(clear_menu_cache, sender=BlogCategory)
开发者ID:cnk-digital-solutions,项目名称:djangocms-blog,代码行数:30,代码来源:cms_menus.py


示例18: ZinniaMenuModifier

from menus.menu_pool import menu_pool


class ZinniaMenuModifier(Modifier):
    """

    """

    def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
        """We want all parts of zinnia to show the blog selected."""
        if post_cut:
            return nodes
        # Find out if it is a Zinnia Page
        try:
            blog_page = Page.objects.filter(title_set__application_urls="ZinniaApphook").get()
        except Page.DoesNotExist:
            blog_page = None
        if blog_page and request.path.startswith("/%s" % blog_page.get_path()):
            for node in nodes:
                if node.title == blog_page.get_title():
                    node.selected = True
        # Not sure what this does?
        count = 0
        for node in nodes:
            node.counter = count
            count += 1
        return nodes


menu_pool.register_modifier(ZinniaMenuModifier)
开发者ID:baconz,项目名称:florencegrendedotcom,代码行数:30,代码来源:menu.py


示例19: MenuExternalUrlMod

from menus.base import Modifier
from menus.menu_pool import menu_pool
from menu_external_urls.models import MenuExternalUrl


class MenuExternalUrlMod(Modifier):
    """
    Adds ability to link page to an external URL.
    """
    def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
        if post_cut:
            return nodes
        if breadcrumb:
            return nodes
        for node in nodes:
            try:
                #Load External URL into nodes
                menu_external_url = MenuExternalUrl.objects.get(page=(node.id-1))
                node.url = menu_external_url.menu_external_url
                node.external = True
            except:
                pass
        return nodes

menu_pool.register_modifier(MenuExternalUrlMod)
开发者ID:fsboehme,项目名称:django-theherk-external-urls,代码行数:25,代码来源:menu.py


示例20: register

def register():
    menu_pool.register_modifier(Marker)
    menu_pool.register_modifier(LoginRequired)
    menu_pool.register_modifier(Level)
    
开发者ID:DrMeers,项目名称:django-cms-2.0,代码行数:4,代码来源:modifiers.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python menu_tags.show_menu函数代码示例发布时间:2022-05-27
下一篇:
Python menu_pool.register_menu函数代码示例发布时间: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