本文整理匯總了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))