当前位置: 首页>>代码示例>>Python>>正文


Python menu_pool.register_menu函数代码示例

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


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


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