本文整理汇总了Python中cms.toolbar.toolbar.CMSToolbar.get_left_items方法的典型用法代码示例。如果您正苦于以下问题:Python CMSToolbar.get_left_items方法的具体用法?Python CMSToolbar.get_left_items怎么用?Python CMSToolbar.get_left_items使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cms.toolbar.toolbar.CMSToolbar
的用法示例。
在下文中一共展示了CMSToolbar.get_left_items方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_toolbar_with_items
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import get_left_items [as 别名]
def test_toolbar_with_items(self):
"""
Test that PageMeta/TitleMeta items are present for superuser if PageMeta/TitleMeta exists for current page
"""
from cms.toolbar.toolbar import CMSToolbar
page1, page2 = self.get_pages()
page_ext = PageMeta.objects.create(extended_object=page1)
request = self.get_page_request(page1, self.user, '/', edit=True)
toolbar = CMSToolbar(request)
toolbar.get_left_items()
page_menu = toolbar.menus['page']
meta_menu = page_menu.find_items(SubMenu, name=force_text(PAGE_META_MENU_TITLE))[0].item
try:
pagemeta_menu = meta_menu.find_items(ModalItem, name="{0}...".format(force_text(PAGE_META_ITEM_TITLE)))
self.assertEqual(len(pagemeta_menu), 1)
except AssertionError:
pagemeta_menu = meta_menu.find_items(ModalItem, name="{0} ...".format(force_text(PAGE_META_ITEM_TITLE)))
self.assertEqual(len(pagemeta_menu), 1)
self.assertTrue(pagemeta_menu[0].item.url.startswith(reverse('admin:djangocms_page_meta_pagemeta_change', args=(page_ext.pk,))))
for title in page1.title_set.all():
language = get_language_object(title.language)
try:
titlemeta_menu = meta_menu.find_items(ModalItem, name='{0}...'.format(language['name']))
self.assertEqual(len(titlemeta_menu), 1)
except AssertionError:
titlemeta_menu = meta_menu.find_items(ModalItem, name='{0} ...'.format(language['name']))
self.assertEqual(len(titlemeta_menu), 1)
try:
title_ext = TitleMeta.objects.get(extended_object_id=title.pk)
self.assertTrue(titlemeta_menu[0].item.url.startswith(reverse('admin:djangocms_page_meta_titlemeta_change', args=(title_ext.pk,))))
except TitleMeta.DoesNotExist:
self.assertTrue(titlemeta_menu[0].item.url.startswith(reverse('admin:djangocms_page_meta_titlemeta_add')))
示例2: test_toolbar_with_items
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import get_left_items [as 别名]
def test_toolbar_with_items(self):
"""
Test that PageTags/TitleTags items are present for superuser if PageTags/TitleTags exists for current page
"""
from cms.toolbar.toolbar import CMSToolbar
page1, page2 = self.get_pages()
page_ext = PageTags.objects.create(extended_object=page1)
title_tags = TitleTags.objects.create(extended_object=page1.get_title_obj('en'))
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_text(PAGE_TAGS_MENU_TITLE))[0].item
pagetags_menu = tags_menu.find_items(ModalItem, name="{0}...".format(force_text(PAGE_TAGS_ITEM_TITLE)))
self.assertEqual(len(pagetags_menu), 1)
self.assertEqual(len(pagetags_menu), 1)
self.assertTrue(pagetags_menu[0].item.url.startswith(reverse('admin:djangocms_page_tags_pagetags_change', args=(page_ext.pk,))))
url_change = False
url_add = False
for title in page1.title_set.all():
language = get_language_object(title.language)
titletags_menu = tags_menu.find_items(ModalItem, name='{0}...'.format(language['name']))
self.assertEqual(len(titletags_menu), 1)
try:
title_ext = TitleTags.objects.get(extended_object_id=title.pk)
self.assertEqual(title_ext, title_tags)
self.assertTrue(titletags_menu[0].item.url.startswith(reverse('admin:djangocms_page_tags_titletags_change', args=(title_ext.pk,))))
url_change = True
except TitleTags.DoesNotExist:
self.assertTrue(titletags_menu[0].item.url.startswith(reverse('admin:djangocms_page_tags_titletags_add')))
url_add = True
self.assertTrue(url_change and url_add)
示例3: test_toolbar_with_an_existing_usersetting
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import get_left_items [as 别名]
def test_toolbar_with_an_existing_usersetting(self):
"""
Test that UserSettings toolbar item URL is for change_view for superuser
if UserSettings already exists for current site
"""
usersettings_model_opts = self.UserSettings._meta
usersettings_obj = self.UserSettings.objects.create(**self.usersettings_data)
from cms.toolbar.toolbar import CMSToolbar
page = self.get_pages()
request = self.get_page_request(page, self.user, '/', edit=True)
toolbar = CMSToolbar(request)
toolbar.get_left_items()
admin_menu = toolbar.menus[ADMIN_MENU_IDENTIFIER]
MENU_ITEM_TITLE = usersettings_model_opts.verbose_name
change_url = '%s?%s' % (
reverse('admin:%s_%s_change' % (
usersettings_model_opts.app_label,
usersettings_model_opts.module_name), args=(usersettings_obj.pk,)),
IS_POPUP_VAR)
usersettings_menu = \
admin_menu.find_items(ModalItem, name='%s ...' % force_unicode(MENU_ITEM_TITLE))
self.assertEqual(change_url, usersettings_menu[0].item.url)
示例4: test_get_alphabetical_insert_position
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import get_left_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)
示例5: test_toolbar
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import get_left_items [as 别名]
def test_toolbar(self):
"""
Test that PageMeta/TitleMeta items are present for superuser
"""
from cms.toolbar.toolbar import CMSToolbar
NEW_CMS_LANGS = {
1: [
{
'code': 'en',
'name': 'English',
'public': True,
},
{
'code': 'it',
'name': 'Italiano',
'public': True,
},
],
'default': {
'hide_untranslated': False,
},
}
page1, page2 = self.get_pages()
with self.settings(CMS_LANGUAGES=NEW_CMS_LANGS):
request = self.get_page_request(page1, self.user, '/', edit=True)
toolbar = CMSToolbar(request)
toolbar.get_left_items()
page_menu = toolbar.menus['page']
meta_menu = page_menu.find_items(SubMenu, name=force_text(PAGE_META_MENU_TITLE))[0].item
try:
self.assertEqual(len(meta_menu.find_items(ModalItem, name="{0}...".format(force_text(PAGE_META_ITEM_TITLE)))), 1)
except AssertionError:
self.assertEqual(len(meta_menu.find_items(ModalItem, name="{0} ...".format(force_text(PAGE_META_ITEM_TITLE)))), 1)
self.assertEqual(len(meta_menu.find_items(ModalItem)), len(NEW_CMS_LANGS[1])+1)
示例6: test_no_page
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import get_left_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, [])
示例7: test_no_perm
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import get_left_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, [])
示例8: test_toolbar
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import get_left_items [as 别名]
def test_toolbar(self):
"""
Test that PageSitemapProperties item is 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.menus['page']
self.assertEqual(len(page_menu.find_items(ModalItem, name="%s ..." % force_text(PAGE_SITEMAP_MENU_TITLE))), 1)
示例9: test_button_consistency_staff
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import get_left_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)
示例10: test_toolbar
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import get_left_items [as 别名]
def test_toolbar(self):
"""
Test that PageMeta/TitleMeta 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.menus['page']
meta_menu = page_menu.find_items(SubMenu, name=force_unicode(PAGE_META_MENU_TITLE))[0].item
self.assertEqual(len(meta_menu.find_items(ModalItem, name="%s ..." % force_unicode(PAGE_META_ITEM_TITLE))), 1)
self.assertEqual(len(meta_menu.find_items(ModalItem)), len(self.languages) + 1)
示例11: test_perm
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import get_left_items [as 别名]
def test_perm(self):
"""
Test that page meta 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.menus['page']
self.assertEqual(len(page_menu.find_items(ModalItem, name="%s ..." % force_text(PAGE_SITEMAP_MENU_TITLE))), 1)
示例12: test_perm_permissions
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import get_left_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, [])
示例13: test_perm
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import get_left_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)
示例14: test_toolbar_with_items
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import get_left_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])
toolbar = CMSToolbar(request)
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)
示例15: test_no_perm
# 需要导入模块: from cms.toolbar.toolbar import CMSToolbar [as 别名]
# 或者: from cms.toolbar.toolbar.CMSToolbar import get_left_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, [])