本文整理汇总了Python中cms.toolbar.toolbar.CMSToolbar.get_right_items方法的典型用法代码示例。如果您正苦于以下问题:Python CMSToolbar.get_right_items方法的具体用法?Python CMSToolbar.get_right_items怎么用?Python CMSToolbar.get_right_items使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cms.toolbar.toolbar.CMSToolbar
的用法示例。
在下文中一共展示了CMSToolbar.get_right_items方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_alphabetical_insert_position
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import get_right_items [as 别名]
def test_get_alphabetical_insert_position(self):
page = create_page("toolbar-page", "nav_playground.html", "en",
published=True)
request = self.get_page_request(page, self.get_staff(), '/')
toolbar = CMSToolbar(request)
toolbar.get_left_items()
toolbar.get_right_items()
admin_menu = toolbar.get_or_create_menu(ADMIN_MENU_IDENTIFIER, 'TestAppMenu')
# Insert alpha
alpha_position = admin_menu.get_alphabetical_insert_position('menu-alpha', SubMenu, None)
# As this will be the first item added to this, this use should return the default, or namely None
if not alpha_position:
alpha_position = admin_menu.find_first(Break, identifier=ADMINISTRATION_BREAK) + 1
admin_menu.get_or_create_menu('menu-alpha', 'menu-alpha', position=alpha_position)
# Insert gamma (should return alpha_position + 1)
gamma_position = admin_menu.get_alphabetical_insert_position('menu-gamma', SubMenu)
self.assertEqual(int(gamma_position), int(alpha_position) + 1)
admin_menu.get_or_create_menu('menu-gamma', 'menu-gamma', position=gamma_position)
# Where should beta go? It should go right where gamma is now...
beta_position = admin_menu.get_alphabetical_insert_position('menu-beta', SubMenu)
self.assertEqual(beta_position, gamma_position)
示例2: test_button_consistency_staff
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import get_right_items [as 别名]
def test_button_consistency_staff(self):
"""
Tests that the buttons remain even when the language changes.
"""
user = self.get_staff()
cms_page = create_page("test-en", "nav_playground.html", "en", published=True)
create_title("de", "test-de", cms_page)
en_request = self.get_page_request(cms_page, user, edit=True)
en_toolbar = CMSToolbar(en_request)
self.assertEqual(len(en_toolbar.get_left_items() + en_toolbar.get_right_items()), 6)
de_request = self.get_page_request(cms_page, user, path="/de/", edit=True, lang_code="de")
de_toolbar = CMSToolbar(de_request)
self.assertEqual(len(de_toolbar.get_left_items() + de_toolbar.get_right_items()), 6)
示例3: test_template_change_permission
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import get_right_items [as 别名]
def test_template_change_permission(self):
with SettingsOverride(CMS_PERMISSIONS=True):
page = create_page("test", "nav_playground.html", "en", published=True)
request = self.get_page_request(page, self.get_nonstaff())
toolbar = CMSToolbar(request)
items = toolbar.get_left_items() + toolbar.get_right_items()
self.assertEqual([item for item in items if item.css_class_suffix == "templates"], [])
示例4: test_anon
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import get_right_items [as 别名]
def test_anon(self):
page = create_page("test", "nav_playground.html", "en")
request = self.get_page_request(page, self.get_anon())
toolbar = CMSToolbar(request)
items = toolbar.get_left_items() + toolbar.get_right_items()
self.assertEqual(len(items), 0)
示例5: test_nonstaff
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import get_right_items [as 别名]
def test_nonstaff(self):
page = create_page("test", "nav_playground.html", "en", published=True)
request = self.get_page_request(page, self.get_nonstaff())
toolbar = CMSToolbar(request)
items = toolbar.get_left_items() + toolbar.get_right_items()
# Logo + edit-mode + logout
self.assertEqual(len(items), 0)
示例6: test_publish_button
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import get_right_items [as 别名]
def test_publish_button(self):
page = create_page("test", "nav_playground.html", "en", published=True)
request = self.get_page_request(page, self.get_superuser(), edit=True)
toolbar = CMSToolbar(request)
self.assertTrue(toolbar.edit_mode)
items = toolbar.get_left_items() + toolbar.get_right_items()
self.assertEqual(len(items), 7)
示例7: test_no_page_anon
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import get_right_items [as 别名]
def test_no_page_anon(self):
request = self.get_page_request(None, self.get_anon(), '/')
toolbar = CMSToolbar(request)
toolbar.populate()
toolbar.post_template_populate()
items = toolbar.get_left_items() + toolbar.get_right_items()
self.assertEqual(len(items), 0)
示例8: test_not_is_staff
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import get_right_items [as 别名]
def test_not_is_staff(self):
request = RequestFactory().get("/en/?edit")
request.session = {}
request.LANGUAGE_CODE = "en"
request.user = AnonymousUser()
toolbar = CMSToolbar(request)
self.assertEqual(len(toolbar.get_left_items()), 0)
self.assertEqual(len(toolbar.get_right_items()), 0)
示例9: test_toolbar_with_items
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import get_right_items [as 别名]
def test_toolbar_with_items(self):
"""
Test that Blog toolbar is present and contains all items
"""
from cms.toolbar.toolbar import CMSToolbar
posts = self.get_posts()
pages = self.get_pages()
request = self.get_page_request(pages[0], self.user, r'/en/blog/', edit=True)
setattr(request, BLOG_CURRENT_POST_IDENTIFIER, posts[0])
posts[0].publish = False
posts[0].save()
toolbar = CMSToolbar(request)
toolbar.populate()
toolbar.post_template_populate()
toolbar.get_left_items()
blog_menu = toolbar.menus['djangocms_blog']
self.assertEqual(len(blog_menu.find_items(ModalItem, url=reverse('admin:djangocms_blog_post_changelist'))), 1)
self.assertEqual(len(blog_menu.find_items(ModalItem, url=reverse('admin:djangocms_blog_post_add'))), 1)
self.assertEqual(len(blog_menu.find_items(ModalItem, url=reverse('admin:djangocms_blog_post_change', args=(posts[0].pk,)))), 1)
# Publish button only appears if current post is unpublished
right = toolbar.get_right_items()
buttons = sum([item.buttons for item in right if isinstance(item, ButtonList)], [])
self.assertTrue([button for button in buttons if force_text(button.name) == 'Publish Blog now'])
# Publish button does not appears if current post is published
posts[0].publish = True
posts[0].save()
toolbar = CMSToolbar(request)
toolbar.populate()
toolbar.post_template_populate()
right = toolbar.get_right_items()
buttons = sum([item.buttons for item in right if isinstance(item, ButtonList)], [])
self.assertFalse([button for button in buttons if force_text(button.name) == 'Publish Blog now'])
# Publish button does not appears if other posts but the current one are unpublished
posts[1].publish = True
posts[1].save()
toolbar = CMSToolbar(request)
toolbar.populate()
toolbar.post_template_populate()
right = toolbar.get_right_items()
buttons = sum([item.buttons for item in right if isinstance(item, ButtonList)], [])
self.assertFalse([button for button in buttons if force_text(button.name) == 'Publish Blog now'])
示例10: test_no_page_superuser
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import get_right_items [as 别名]
def test_no_page_superuser(self):
request = self.get_page_request(None, self.get_superuser(), "/")
toolbar = CMSToolbar(request)
items = toolbar.get_left_items() + toolbar.get_right_items()
# Logo + edit-mode + admin-menu + logout
self.assertEqual(len(items), 3)
admin_items = toolbar.get_or_create_menu(ADMIN_MENU_IDENTIFIER, "Test").get_items()
self.assertEqual(len(admin_items), 7, admin_items)
示例11: test_button_consistency_staff
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import get_right_items [as 别名]
def test_button_consistency_staff(self):
"""
Tests that the buttons remain even when the language changes.
"""
user = self.get_staff()
cms_page = create_page('test-en', 'nav_playground.html', 'en', published=True)
create_title('de', 'test-de', cms_page)
cms_page.publish('de')
en_request = self.get_page_request(cms_page, user, edit=True)
en_toolbar = CMSToolbar(en_request)
en_toolbar.populate()
en_toolbar.post_template_populate()
self.assertEqual(len(en_toolbar.get_left_items() + en_toolbar.get_right_items()), 6)
de_request = self.get_page_request(cms_page, user, path='/de/', edit=True, lang_code='de')
de_toolbar = CMSToolbar(de_request)
de_toolbar.populate()
de_toolbar.post_template_populate()
self.assertEqual(len(de_toolbar.get_left_items() + de_toolbar.get_right_items()), 6)
示例12: test_publish_button
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import get_right_items [as 别名]
def test_publish_button(self):
page = create_page('test', 'nav_playground.html', 'en', published=True)
request = self.get_page_request(page, self.get_superuser(), edit=True)
toolbar = CMSToolbar(request)
toolbar.populate()
toolbar.post_template_populate()
self.assertTrue(toolbar.edit_mode)
items = toolbar.get_left_items() + toolbar.get_right_items()
self.assertEqual(len(items), 7)
示例13: test_no_publish_button
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import get_right_items [as 别名]
def test_no_publish_button(self):
page = create_page("test", "nav_playground.html", "en", published=True)
request = self.get_page_request(page, self.get_staff(), edit=True)
toolbar = CMSToolbar(request)
self.assertTrue(page.has_change_permission(request))
self.assertFalse(page.has_publish_permission(request))
self.assertTrue(toolbar.edit_mode)
items = toolbar.get_left_items() + toolbar.get_right_items()
# Logo + edit-mode + templates + page-menu + admin-menu + logout
self.assertEqual(len(items), 6)
示例14: test_no_page_staff
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import get_right_items [as 别名]
def test_no_page_staff(self):
request = self.get_page_request(None, self.get_staff(), '/')
toolbar = CMSToolbar(request)
toolbar.populate()
toolbar.post_template_populate()
items = toolbar.get_left_items() + toolbar.get_right_items()
# Logo + admin-menu + logout
self.assertEqual(len(items), 2, items)
admin_items = toolbar.get_or_create_menu(ADMIN_MENU_IDENTIFIER, 'Test').get_items()
self.assertEqual(len(admin_items), 6, admin_items)
示例15: test_out_of_order
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import get_right_items [as 别名]
def test_out_of_order(self):
page = create_page("toolbar-page", "nav_playground.html", "en",
published=True)
request = self.get_page_request(page, self.get_staff(), '/')
toolbar = CMSToolbar(request)
menu1 = toolbar.get_or_create_menu("test")
menu2 = toolbar.get_or_create_menu("test", "Test", side=toolbar.RIGHT, position=2)
self.assertEqual(menu1, menu2)
self.assertEqual(menu1.name, 'Test')
self.assertEqual(len(toolbar.get_right_items()), 1)