本文整理汇总了Python中cms.toolbar.toolbar.CMSToolbar.find_items方法的典型用法代码示例。如果您正苦于以下问题:Python CMSToolbar.find_items方法的具体用法?Python CMSToolbar.find_items怎么用?Python CMSToolbar.find_items使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cms.toolbar.toolbar.CMSToolbar
的用法示例。
在下文中一共展示了CMSToolbar.find_items方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_no_page
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import find_items [as 别名]
def test_no_page(self):
"""
Test that no page menu is present if request not in a page
"""
from cms.toolbar.toolbar import CMSToolbar
request = self.get_page_request(None, self.user, '/', edit=True)
toolbar = CMSToolbar(request)
toolbar.get_left_items()
page_menu = toolbar.find_items(Menu, name='Page')
self.assertEqual(page_menu, [])
示例2: test_no_perm
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import find_items [as 别名]
def test_no_perm(self):
"""
Test that no page menu is present if user has no perm
"""
from cms.toolbar.toolbar import CMSToolbar
page1, page2 = self.get_pages()
request = self.get_page_request(page1, self.user_staff, '/', edit=True)
toolbar = CMSToolbar(request)
toolbar.get_left_items()
page_menu = toolbar.find_items(Menu, name='Page')
self.assertEqual(page_menu, [])
示例3: test_perm_permissions
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import find_items [as 别名]
def test_perm_permissions(self):
"""
Test that no page menu is present if user has general page Page.change_perm but not permission on current page
"""
from cms.toolbar.toolbar import CMSToolbar
page1, page2 = self.get_pages()
self.user_staff.user_permissions.add(Permission.objects.get(codename='change_page'))
self.user_staff = User.objects.get(pk=self.user_staff.pk)
request = self.get_page_request(page1, self.user_staff, '/', edit=True)
toolbar = CMSToolbar(request)
toolbar.get_left_items()
page_menu = toolbar.find_items(Menu, name='Page')
self.assertEqual(page_menu, [])
示例4: test_toolbar
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import find_items [as 别名]
def test_toolbar(self):
"""
Test that PageTags/TitleTags items are present for superuser
"""
from cms.toolbar.toolbar import CMSToolbar
page1, page2 = self.get_pages()
request = self.get_page_request(page1, self.user, '/', edit=True)
toolbar = CMSToolbar(request)
toolbar.get_left_items()
page_menu = toolbar.find_items(Menu, name='Page')[0].item
tags_menu = page_menu.find_items(SubMenu, name=force_unicode(PAGE_TAGS_MENU_TITLE))[0].item
self.assertEqual(len(tags_menu.find_items(ModalItem, name="%s ..." % force_unicode(PAGE_TAGS_ITEM_TITLE))), 1)
self.assertEqual(len(tags_menu.find_items(ModalItem)), len(self.languages)+1)
示例5: test_perm
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import find_items [as 别名]
def test_perm(self):
"""
Test that page tags menu is present if user has Page.change_perm
"""
from cms.toolbar.toolbar import CMSToolbar
page1, page2 = self.get_pages()
self.user_staff.user_permissions.add(Permission.objects.get(codename='change_page'))
self.user_staff = User.objects.get(pk=self.user_staff.pk)
request = self.get_page_request(page1, self.user_staff, '/', edit=True)
toolbar = CMSToolbar(request)
toolbar.get_left_items()
page_menu = toolbar.find_items(Menu, name='Page')[0].item
tags_menu = page_menu.find_items(SubMenu, name=force_unicode(PAGE_TAGS_MENU_TITLE))[0].item
self.assertEqual(len(tags_menu.find_items(ModalItem, name="%s ..." % force_unicode(PAGE_TAGS_ITEM_TITLE))), 1)
示例6: test_no_perm
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import find_items [as 别名]
def test_no_perm(self):
"""
Test that no page menu is present if user has no perm
"""
from cms.toolbar.toolbar import CMSToolbar
page1, __ = self.get_pages()
request = self.get_page_request(page1, self.user_staff, '/', edit=True)
toolbar = CMSToolbar(request)
toolbar.get_left_items()
page_menu = toolbar.find_items(Menu, name='Page')
try:
self.assertEqual(page_menu, [])
except AssertionError:
meta_menu = page_menu[0].item.find_items(SubMenu, name=force_text(PAGE_META_MENU_TITLE))
self.assertEqual(meta_menu, [])
示例7: test_perm_permissions
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import find_items [as 别名]
def test_perm_permissions(self):
"""
Test that no page menu is present if user has general page Page.change_perm but not permission on current page
"""
from cms.toolbar.toolbar import CMSToolbar
page1, __ = self.get_pages()
self.user_staff.user_permissions.add(Permission.objects.get(codename='change_page'))
self.user_staff = User.objects.get(pk=self.user_staff.pk)
request = self.get_page_request(page1, self.user_staff, '/', edit=True)
toolbar = CMSToolbar(request)
toolbar.get_left_items()
page_menu = toolbar.find_items(Menu, name='Page')
try:
self.assertEqual(page_menu, [])
except AssertionError:
meta_menu = page_menu[0].item.find_items(SubMenu, name=force_text(PAGE_META_MENU_TITLE))
self.assertEqual(meta_menu, [])