本文整理汇总了Python中horizon.Panel方法的典型用法代码示例。如果您正苦于以下问题:Python horizon.Panel方法的具体用法?Python horizon.Panel怎么用?Python horizon.Panel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类horizon
的用法示例。
在下文中一共展示了horizon.Panel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_dashboard
# 需要导入模块: import horizon [as 别名]
# 或者: from horizon import Panel [as 别名]
def test_dashboard(self):
cats = horizon.get_dashboard("cats")
self.assertEqual(base.Horizon, cats._registered_with)
self.assertQuerysetEqual(cats.get_panels(),
['<Panel: kittens>',
'<Panel: tigers>'])
self.assertEqual("/cats/", cats.get_absolute_url())
self.assertEqual("Cats", cats.name)
# Test registering a module with a dashboard that defines panels
# as a panel group.
cats.register(MyPanel)
self.assertQuerysetEqual(cats.get_panel_groups()['other'],
['<Panel: myslug>'])
# Test that panels defined as a tuple still return a PanelGroup
dogs = horizon.get_dashboard("dogs")
self.assertQuerysetEqual(dogs.get_panel_groups().values(),
['<PanelGroup: default>'])
# Test registering a module with a dashboard that defines panels
# as a tuple.
dogs = horizon.get_dashboard("dogs")
dogs.register(MyPanel)
self.assertQuerysetEqual(dogs.get_panels(),
['<Panel: puppies>',
'<Panel: myslug>'])
示例2: test_panel_without_slug_fails
# 需要导入模块: import horizon [as 别名]
# 或者: from horizon import Panel [as 别名]
def test_panel_without_slug_fails(self):
class InvalidPanel(horizon.Panel):
name = 'Invalid'
self.assertRaises(ImproperlyConfigured, InvalidPanel)
示例3: test_customize_dashboard
# 需要导入模块: import horizon [as 别名]
# 或者: from horizon import Panel [as 别名]
def test_customize_dashboard(self):
cats = horizon.get_dashboard("cats")
self.assertEqual("WildCats", cats.name)
self.assertQuerysetEqual(cats.get_panels(),
['<Panel: kittens>'])
with self.assertRaises(base.NotRegistered):
horizon.get_dashboard("dogs")
示例4: test_rbac_panels
# 需要导入模块: import horizon [as 别名]
# 或者: from horizon import Panel [as 别名]
def test_rbac_panels(self):
context = {'request': self.request}
cats = horizon.get_dashboard("cats")
self.assertEqual(cats._registered_with, base.Horizon)
self.assertQuerysetEqual(cats.get_panels(),
['<Panel: rbac_panel_no>'])
self.assertFalse(cats.can_access(context))
dogs = horizon.get_dashboard("dogs")
self.assertEqual(dogs._registered_with, base.Horizon)
self.assertQuerysetEqual(dogs.get_panels(),
['<Panel: rbac_panel_yes>'])
self.assertTrue(dogs.can_access(context))