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

Python menu_pool.register_menu函数代码示例

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

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



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

示例1: ProblemsMenu

from django.core.urlresolvers import reverse
from menus.menu_pool import menu_pool
from cms.menu_bases import CMSAttachMenu
from menus.base import NavigationNode

class ProblemsMenu(CMSAttachMenu):
    name = 'Problems Menu'
    def get_nodes(self, req):
        nodes = []
        nodes.append(NavigationNode('Geometric', reverse('problems.views.subindex_geometric'), 0))
        nodes.append(NavigationNode('Control', reverse('problems.views.subindex_control'), 0))
        return nodes

menu_pool.register_menu(ProblemsMenu)
开发者ID:amdshameer,项目名称:plannerarena,代码行数:14,代码来源:menu.py


示例2: WikiPageMenu

# -*- coding: utf-8 -*-
from django.utils.translation import ugettext as _

from cms.menu_bases import CMSAttachMenu

from menus.base import NavigationNode
from menus.menu_pool import menu_pool

from wiki.models import WikiPage

class WikiPageMenu(CMSAttachMenu):
    """Wiki Page Menu
    
    Create a Wiki Page menu in breadcrumb.
    """
    name = _("Wiki Page Menu")

    def get_nodes(self, request):
        nodes=[]
        wikipages = WikiPage.objects.all()
        for wikipage in wikipages:
            nodes.append(NavigationNode(wikipage.slug, 
                wikipage.slug, 
                wikipage.pk))
        return nodes


menu_pool.register_menu(WikiPageMenu)

开发者ID:indexofire,项目名称:pyrix-site,代码行数:28,代码来源:menu.py


示例3: hasattr

                               .language(language)
                               .active_translations(language))

        if hasattr(self, 'instance') and self.instance:  # pragma: no cover
            # If self has a property `instance`, then we're using django CMS
            # 3.0.12 or later, which supports using CMSAttachMenus on multiple,
            # apphook'ed pages, each with their own apphook configuration. So,
            # here we modify the queryset to reflect this.
            app = apphook_pool.get_apphook(self.instance.application_urls)
            if app:
                things = things.namespace(self.instance.application_namespace)

        for thing in things:
            # This try/except seems like overkill here, but if this fails for
            # any reason, this **and any further menus, even from other apps**
            # may not get loaded, so we're extra careful.
            try:
                url = thing.get_absolute_url(language=language)
                node = NavigationNode(thing.name, url, thing.pk)
                nodes.append(node)
            except NoReverseMatch:  # pragma: no cover
                pass

        return nodes

menu_pool.register_menu(ThingsMenu)


# Consider, are there other ways of making menus that users might wish to
# choose from?
开发者ID:aldryn,项目名称:things,代码行数:30,代码来源:menu.py


示例4: ImportMenu

from django.utils.translation import ugettext_lazy as _
from django.core.urlresolvers import reverse

from menus.base import Modifier, Menu, NavigationNode
from menus.menu_pool import menu_pool
from cms.menu_bases import CMSAttachMenu


class ImportMenu(CMSAttachMenu):
    
    name = _("Import Menu")
    
    def get_nodes(self, request):
        nodes = []

        node = NavigationNode(
            _('My Uploads'),
            reverse('importer-import-list'),
            181
        )
        nodes.append(node)

        
        return nodes
    
menu_pool.register_menu(ImportMenu)


开发者ID:hzlf,项目名称:openbroadcast.org,代码行数:26,代码来源:menu.py


示例5: _

            _('Releases'),
            reverse('alibrary-release-list', args=[]),
            123
        )
        nodes.append(node)
        node = NavigationNode(
            _('Artists'),
            reverse('ArtistListlView', args=[]),
            123
        )
        nodes.append(node)
        """
        
        return nodes
    
menu_pool.register_menu(LibraryMenu)






class ReleaseMenu(CMSAttachMenu):
    
    name = _("Release Menu")
    
    def get_nodes(self, request):
        nodes = []
        """
        for release in Release.objects.active():
            try:
开发者ID:alainwolf,项目名称:openbroadcast.org,代码行数:31,代码来源:menu.py


示例6: ExportMenu

from exporter.models import Export

class ExportMenu(CMSAttachMenu):
    
    name = _("Export Menu")
    
    def get_nodes(self, request):
        nodes = []
        
        """"""
        node = NavigationNode(
            _('My Exports'),
            reverse('exporter-export-list'),
            191
        )
        nodes.append(node)
        
        """"""
        node = NavigationNode(
            _('Settings'),
            reverse('exporter-export-settings'),
            192
        )
        nodes.append(node)
        
        
        return nodes
    
menu_pool.register_menu(ExportMenu)
开发者ID:hzlf,项目名称:openbroadcast,代码行数:29,代码来源:menu.py


示例7: reverse

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


class EntryModifier(Modifier):
    """Menu Modifier for entries,
    hide the MenuEntry 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'):
                node.visible = False
        return nodes


menu_pool.register_menu(EntryMenu)
menu_pool.register_menu(CategoryMenu)
menu_pool.register_menu(AuthorMenu)
menu_pool.register_menu(TagMenu)
menu_pool.register_modifier(EntryModifier)
开发者ID:Immediatic,项目名称:cmsplugin-zinnia,代码行数:30,代码来源:menu.py


示例8: CategoryIcon

        nodes = []
        for category in Category.objects.all().order_by("parent", "ordering"):
            nodes.append(NavigationNode(title=category.name, 
                                        url=category.get_absolute_url(), 
                                        id=category.pk, 
                                        parent_id=category.parent_id,
                                        attr=dict(slug=category.slug)))

        return nodes

class CategoryIcon(Modifier):
    """
    navigation modifier that adds icon attribute
    """
    icons = {}
    def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
        if breadcrumb or not post_cut:
            return nodes
        ns = CatalogMenu.__name__
        if not self.icons:
            for ci in CategoryImage.objects.filter(icon=True):
                self.icons[ci.category.pk] = ci.image.file.url 
        if self.icons:
            for node in nodes:
                #print node.id, node.title, ', ns:', getattr(node, 'namespace', 'None')
                if node.namespace == ns and self.icons.get(node.id, None):
                    node.attr['icon'] = self.icons.get(node.id)
        return nodes
    
menu_pool.register_menu(CatalogMenu)
menu_pool.register_modifier(CategoryIcon)
开发者ID:airtonix,项目名称:django-simple-shop,代码行数:31,代码来源:menu.py


示例9: NavigationNode

        
        """"""
        node = NavigationNode(
            _('All Profiles'),
            reverse('profiles-profile-list'),
            171
        )
        nodes.append(node)
        
        if request.user.is_active:
            node = NavigationNode(
                _('My Profile'),
                reverse('profiles-profile-detail', args=[request.user.username]),
                111
            )
            nodes.append(node)
            
            
            node = NavigationNode(
                _('Edit my Profile'),
                reverse('profiles-profile-edit'),
                121
            )
            nodes.append(node)
        
        return nodes
    
menu_pool.register_menu(ProfileMenu)


开发者ID:hzlf,项目名称:openbroadcast,代码行数:27,代码来源:menu.py


示例10: get_fallback_languages

            fallbacks = get_fallback_languages(lang)
            for l in fallbacks:
                titles = list(get_title_queryset(request).filter(page__in=ids, language=l))
                for title in titles:
                    for page in pages:# add the title and slugs and some meta data
                        if title.page_id == page.pk:
                            if not hasattr(page, "title_cache"):
                                page.title_cache = {}
                            page.title_cache[title.language] = title
                            nodes.append(page_to_node(page, home, home_cut))
                            ids.remove(page.pk)
                            break
                if not ids:
                    break
        return nodes  
menu_pool.register_menu(CMSMenu)

class NavExtender(Modifier):
    def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
        if post_cut:
            return nodes
        exts = []
        # rearrange the parent relations
        home = None
        for node in nodes:
            if node.attr.get("is_home", False):
                home = node
            extenders = node.attr.get("navigation_extenders", None)
            if extenders:
                for ext in extenders:
                    if not ext in exts:
开发者ID:wiremine,项目名称:django-cms,代码行数:31,代码来源:menu.py


示例11: NavigationNode

                url = person.get_absolute_url(language=language)
            except NoReverseMatch:
                url = None
            if url:
                node = NavigationNode(
                    person.safe_translation_getter(
                        "name", default=_("person: {0}").format(person.pk), language_code=language
                    ),
                    url,
                    person.pk,
                )
                nodes.append(node)
        return nodes


menu_pool.register_menu(PersonMenu)


class GroupMenu(CMSAttachMenu):
    """
    Provides an attachable menu of all groups.
    """

    name = _("Aldryn People: Group Menu")

    def get_nodes(self, request):
        nodes = []
        language = get_language_from_request(request, check_path=True)
        groups = Group.objects.language(language).active_translations(language)

        for group in groups:
开发者ID:astagi,项目名称:aldryn-people,代码行数:31,代码来源:menu.py


示例12: reverse

                    months = []

                if not pub_date.month in months:
                    months.append(pub_date.month)
                    nodes.append(NavigationNode(datetime.strftime(pub_date, '%B'),
                        reverse('cmsplugin_news3:news3_archive_month', kwargs={
                            'year': pub_date.year,
                            'month': datetime.strftime(pub_date, '%m'),
                        }), datetime.strftime(pub_date, '%m'), pub_date.year))
                    days = []

                if not pub_date.day in days:
                    days.append(pub_date.day)
                    nodes.append(NavigationNode(datetime.strftime(pub_date, '%d'),
                        reverse('cmsplugin_news3:news3_archive_day', kwargs={
                            'year': pub_date.year,
                            'month': datetime.strftime(pub_date, '%m'),
                            'day': datetime.strftime(pub_date, '%d'),
                        }), datetime.strftime(pub_date, '%d'), datetime.strftime(pub_date, '%m')))
                    slugs = []

                if not item.slug in slugs:
                    slugs.append(item.slug)
                    nodes.append(NavigationNode(
                        item.title, item.get_absolute_url(), item.pk, datetime.strftime(pub_date, '%d')))
        except:
            pass
        return nodes

menu_pool.register_menu(CMSLatestNews3AppMenu)
开发者ID:AlexProfi,项目名称:cmsplugin_news3,代码行数:30,代码来源:menu.py


示例13: TermMenu

from cms.menu_bases import CMSAttachMenu
from menus.base import NavigationNode
from menus.menu_pool import menu_pool
from django.core.urlresolvers import NoReverseMatch
from .models import Term
from django.utils.translation import ugettext_lazy as _


class TermMenu(CMSAttachMenu):
    name = _('Term Menu')

    def get_nodes(self, request):
        '''
        This method is used to build the menu tree.
        '''
        nodes = []
        for term in Term.objects.iterator():
            try:
                node = NavigationNode(
                    unicode(term),
                    term.get_absolute_url(),
                    term.pk,
                )
                nodes.append(node)
            except NoReverseMatch:
                pass
        return nodes


menu_pool.register_menu(TermMenu)
开发者ID:bitdeli-chef,项目名称:django-terms,代码行数:30,代码来源:menu.py


示例14: SliderSubMenu

from django.utils.translation import ugettext_lazy as _
from django.utils.safestring import mark_safe

from menus.base import NavigationNode
from menus.menu_pool import menu_pool
from cms.menu_bases import CMSAttachMenu

from .models import SliderMember


class SliderSubMenu(CMSAttachMenu):

    name = _("Slider Sub-Menu")

    def get_nodes(self, request):
        nodes = []

        for slider in SliderMember.objects.order_by('full_name').all():

            node = NavigationNode(
                mark_safe(slider.full_name),
                slider.get_absolute_url(),
                slider.id,
            )

            nodes.append(node)

        return nodes

menu_pool.register_menu(SliderSubMenu)
开发者ID:serrrgggeee,项目名称:okt,代码行数:30,代码来源:menu.py


示例15: SubCategoryMenu2

				nodes.append(NavigationNode(subcategory.title, "/swivels/"+ category.slug + '/' + subcategory.slug, subcategory.id, category.id*154332345))
		return nodes

#class SubCategoryMenu2(CMSAttachMenu):

#	name = _("aSwivel Products")
#	def get_nodes(self, request):
#		nodes = []
#		cat = request.current_page
#		for category in Category.objects.filter(associated_page__reverse_id = "swivelproduct"):
#			nodes.append(NavigationNode(category.title, "/produits/"+ category.slug + '/', category.id*154332345, None ,None, {'is_extending' : True}))
#			for subcategory in SubCategory.objects.filter(category__id = category.id):
#				nodes.append(NavigationNode(subcategory.title, "/produits/"+ category.slug + '/' + subcategory.slug, subcategory.id, category.id*154332345))
#		return nodes
#menu_pool.register_menu(SubCategoryMenu2)
menu_pool.register_menu(SubCategoryMenu)

class NavExtender(Modifier):
    def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
        if post_cut:
            return nodes
        nodes = sorted(nodes, key=lambda n: n.attr.get("is_extending", None), reverse=True)
        exts = []
        # rearrange the parent relations
        home = None
        for node in nodes:
            if node.attr.get("is_home", False):
                home = node
            extenders = node.attr.get("navigation_extenders", None)
            if extenders:
                for ext in extenders:
开发者ID:sandeep1988,项目名称:django-taimi-project,代码行数:31,代码来源:menu.py


示例16: not

        queryset = Article.objects
        if not (request.toolbar and request.toolbar.edit_mode):
            queryset = queryset.published()
        return queryset

    def get_nodes(self, request):
        nodes = []
        language = get_language_from_request(request, check_path=True)
        articles = self.get_queryset(request).active_translations(language)

        if hasattr(self, 'instance') and self.instance:
            app = apphook_pool.get_apphook(self.instance.application_urls)
            config = app.get_config(self.instance.application_namespace)
            if config:
                articles = articles.filter(app_config=config)

        for article in articles:
            try:
                url = article.get_absolute_url(language=language)
            except NoReverseMatch:
                url = None

            if url:
                node = NavigationNode(article.safe_translation_getter(
                    'title', language_code=language), url, article.pk)
                nodes.append(node)
        return nodes


menu_pool.register_menu(NewsBlogMenu)
开发者ID:mauri1982,项目名称:aldryn-newsblog,代码行数:30,代码来源:menu.py


示例17: PollsMenu

#-*- coding: utf-8 -*-
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _

from cms.menu_bases import CMSAttachMenu
from menus.base import NavigationNode
from menus.menu_pool import menu_pool

from polls.models import Poll


class PollsMenu(CMSAttachMenu):
    name = _("Polls Menu")  # give the menu a name this is required.

    def get_nodes(self, request):
        """
        This method is used to build the menu tree.
        """
        nodes = []
        for poll in Poll.objects.all():
            node = NavigationNode(
                title=poll.question,
                url=reverse('polls:detail', args=(poll.pk,)),
                id=poll.pk,  # unique id for this node within the menu
            )
            nodes.append(node)
        return nodes

menu_pool.register_menu(PollsMenu)
开发者ID:divio,项目名称:djangocms-tutorial-code,代码行数:29,代码来源:menu.py


示例18: SignalBoxMenu

from django.core.urlresolvers import reverse
from menus.base import Menu, NavigationNode
from menus.menu_pool import menu_pool
from django.utils.translation import ugettext_lazy as _

class SignalBoxMenu(Menu):

    def get_nodes(self, request):
        nodes = []

        if request.user.is_staff:
            nodes.insert(0, NavigationNode("Admin site", reverse('admin:index'), 1))
        return nodes

menu_pool.register_menu(SignalBoxMenu)
开发者ID:benwhalley,项目名称:signalbox,代码行数:15,代码来源:menu.py


示例19: galerieSubMenu

from django.utils.translation import ugettext_lazy as _
from django.utils.safestring import mark_safe

from menus.base import NavigationNode
from menus.menu_pool import menu_pool
from cms.menu_bases import CMSAttachMenu

from .models import Rubrique


class galerieSubMenu(CMSAttachMenu):

    name = _("Galerie Sous-Menu")

    def get_nodes(self, request):
        nodes = []

        for rubrique in Rubrique.objects.order_by('nom_rubrique').all():

             node = NavigationNode(
                 mark_safe(rubrique.nom_rubrique),
                 rubrique.get_absolute_url(),
                 rubrique.id,
             )

             nodes.append(node)

        return nodes

menu_pool.register_menu(galerieSubMenu)
开发者ID:geodatup,项目名称:ann,代码行数:30,代码来源:menu.py


示例20: NavigationNode

            title=_(plugin_settings.STORYBASE_PROJECT_LIST_TITLE), 
            url=reverse('project_list'),
            id='projects',
            parent_id=explore.id)
        nodes.append(projects)
        for project in Project.objects.all().order_by('-last_edited'):
            nodes.append(
                NavigationNode(
	                title=project.name,
                    url=project.get_absolute_url(),
                    id=project.project_id,
                    parent_id=projects.id))
                                        
        return nodes

menu_pool.register_menu(StorybaseMenu)

class OrderMenuNodes(Modifier):
    """Modifier that insert custom navigation nodes in a specified order"""
    def move_node(self, nodes, id, position):
        modified_nodes = []
        matched_node = None
        matched_children = []
        # Check to make sure we're trying to insert the explore menu nodes
	    # in a position that actually exists
        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)
开发者ID:jwirfs-brock,项目名称:atlas,代码行数:31,代码来源:menu.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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