本文整理汇总了Python中menus.templatetags.menu_tags.show_menu函数的典型用法代码示例。如果您正苦于以下问题:Python show_menu函数的具体用法?Python show_menu怎么用?Python show_menu使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了show_menu函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_16_softroot
def test_16_softroot(self):
page2 = Page.objects.get(pk=self.page2.pk)
page2.soft_root = True
page2.save()
context = self.get_context(path=page2.get_absolute_url())
nodes = show_menu(context, 0, 100, 100, 100)['children']
self.assertEqual(len(nodes), 1)
self.assertEqual(nodes[0].get_absolute_url(), page2.get_absolute_url())
page3 = Page.objects.get(pk=self.page3.pk)
context = self.get_context(path=page3.get_absolute_url())
nodes = show_menu(context, 0, 100, 100, 100)['children']
self.assertEqual(len(nodes), 1)
self.assertEqual(nodes[0].get_absolute_url(), page2.get_absolute_url())
page1 = Page.objects.get(pk=self.page1.pk)
context = self.get_context(path=page1.get_absolute_url())
nodes = show_menu(context, 0, 100, 100, 100)['children']
self.assertEqual(len(nodes), 2)
self.assertEqual(nodes[0].get_absolute_url(), page1.get_absolute_url())
self.assertEqual(len(nodes[0].children[0].children), 0)
context = self.get_context(path="/no/real/path/")
nodes = show_menu(context, 0, 100, 100, 100)['children']
self.assertEqual(len(nodes), 2)
self.assertEqual(nodes[0].get_absolute_url(), page1.get_absolute_url())
self.assertEqual(len(nodes[0].children[0].children), 0)
page5 = Page.objects.get(pk=self.page5.pk)
context = self.get_context(path=page5.get_absolute_url())
nodes = show_menu(context, 0, 100, 100, 100)['children']
self.assertEqual(len(nodes), 2)
self.assertEqual(nodes[0].get_absolute_url(), page1.get_absolute_url())
self.assertEqual(len(nodes[0].children[0].children), 0)
示例2: test_17_show_submenu_from_non_menu_page
def test_17_show_submenu_from_non_menu_page(self):
page6 = Page.objects.get(pk=self.page6.pk)
context = self.get_context(page6.get_absolute_url())
nodes = show_menu(context, 1, 100, 0, 1)['children']
self.assertEqual(len(nodes), 0)
page7 = Page.objects.get(pk=self.page7.pk)
context = self.get_context(page7.get_absolute_url())
nodes = show_menu(context, 1, 100, 0, 1)['children']
self.assertEqual(len(nodes), 0)
示例3: test_03_only_active_tree
def test_03_only_active_tree(self):
context = self.get_context()
# test standard show_menu
nodes = show_menu(context, 0, 100, 0, 100)['children']
self.assertEqual(len(nodes[1].children), 0)
self.assertEqual(len(nodes[0].children), 1)
self.assertEqual(len(nodes[0].children[0].children), 1)
context = self.get_context(path=self.page4.get_absolute_url())
nodes = show_menu(context, 0, 100, 0, 100)['children']
self.assertEqual(len(nodes[1].children), 1)
self.assertEqual(len(nodes[0].children), 0)
示例4: test_06_only_level_one
def test_06_only_level_one(self):
context = self.get_context()
# test standard show_menu
nodes = show_menu(context, 1, 1, 100, 100)['children']
self.assertEqual(len(nodes), 2)
for node in nodes:
self.assertEqual(len(node.children), 0)
示例5: test_04_only_one_active_level
def test_04_only_one_active_level(self):
context = self.get_context()
# test standard show_menu
nodes = show_menu(context, 0, 100, 0, 1)['children']
self.assertEqual(len(nodes[1].children), 0)
self.assertEqual(len(nodes[0].children), 1)
self.assertEqual(len(nodes[0].children[0].children), 0)
示例6: test_07_only_level_one_active
def test_07_only_level_one_active(self):
context = self.get_context()
# test standard show_menu
nodes = show_menu(context, 1, 1, 0, 100)['children']
self.assertEqual(len(nodes), 1)
self.assertEqual(nodes[0].descendant, True)
self.assertEqual(len(nodes[0].children), 0)
示例7: test_14_unpublished
def test_14_unpublished(self):
page2 = Page.objects.get(pk=self.page2.pk)
page2.published = False
page2.save()
context = self.get_context()
nodes = show_menu(context)['children']
self.assertEqual(len(nodes), 2)
self.assertEqual(len(nodes[0].children), 0)
示例8: test_15_home_not_in_menu
def test_15_home_not_in_menu(self):
page1 = Page.objects.get(pk=self.page1.pk)
page1.in_navigation = False
page1.save()
page4 = Page.objects.get(pk=self.page4.pk)
page4.in_navigation = False
page4.save()
context = self.get_context()
nodes = show_menu(context, 0, 100, 100, 100)['children']
self.assertEqual(len(nodes), 1)
self.assertEqual(nodes[0].get_absolute_url(), "/%s/" % self.page2.get_slug())
self.assertEqual(nodes[0].children[0].get_absolute_url(), "/%s/%s/" % (self.page2.get_slug(), self.page3.get_slug()))
page4 = Page.objects.get(pk=self.page4.pk)
page4.in_navigation = True
page4.save()
menu_pool.clear(settings.SITE_ID)
context = self.get_context()
nodes = show_menu(context, 0, 100, 100, 100)['children']
self.assertEqual(len(nodes), 2)
示例9: test_02_show_menu
def test_02_show_menu(self):
context = self.get_context()
# test standard show_menu
nodes = show_menu(context)['children']
self.assertEqual(len(nodes), 2)
self.assertEqual(nodes[0].selected, True)
self.assertEqual(nodes[0].sibling, False)
self.assertEqual(nodes[0].descendant, False)
self.assertEqual(nodes[0].children[0].descendant, True)
self.assertEqual(nodes[0].children[0].children[0].descendant, True)
self.assertEqual(nodes[0].get_absolute_url(), "/")
self.assertEqual(nodes[1].get_absolute_url(), self.page4.get_absolute_url())
self.assertEqual(nodes[1].sibling, True)
self.assertEqual(nodes[1].selected, False)
示例10: test_05_only_level_zero
def test_05_only_level_zero(self):
context = self.get_context()
# test standard show_menu
nodes = show_menu(context, 0, 0, 0, 0)['children']
for node in nodes:
self.assertEqual(len(node.children), 0)
示例11: test_15_empty_menu
def test_15_empty_menu(self):
Page.objects.all().delete()
request = self.get_request()
nodes = menu_pool.get_nodes(request)
context = self.get_context()
nodes = show_menu(context, 0, 100, 100, 100)['children']
示例12: test_02_show_menu
def test_02_show_menu(self):
context = self.get_context()
nodes = show_menu(context)['children']
self.assertEqual(nodes[0].get_absolute_url(), self.get_pages_root())
self.assertEqual(nodes[0].get_absolute_url(), "/content/")