本文整理汇总了Python中horizon.tables.Row方法的典型用法代码示例。如果您正苦于以下问题:Python tables.Row方法的具体用法?Python tables.Row怎么用?Python tables.Row使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类horizon.tables
的用法示例。
在下文中一共展示了tables.Row方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: allowed
# 需要导入模块: from horizon import tables [as 别名]
# 或者: from horizon.tables import Row [as 别名]
def allowed(self, request, share=None):
if share:
# Row button
return (share.status.upper() in DELETABLE_STATES and
not getattr(share, 'has_snapshot', False))
# Table button. Always return 'True'.
return True
示例2: allowed
# 需要导入模块: from horizon import tables [as 别名]
# 或者: from horizon.tables import Row [as 别名]
def allowed(self, request, share_group=None):
if share_group:
# Row button
return (share_group.status.lower() in ('available', 'error'))
# Table button. Always return 'True'
return True
示例3: test_table_rendering
# 需要导入模块: from horizon import tables [as 别名]
# 或者: from horizon.tables import Row [as 别名]
def test_table_rendering(self):
self.table = MyTable(self.request, TEST_DATA)
# Table actions
table_actions = self.table.render_table_actions()
resp = http.HttpResponse(table_actions)
self.assertContains(resp, "table_search", 1)
self.assertContains(resp, "my_table__filter__q", 1)
self.assertContains(resp, "my_table__delete", 1)
self.assertContains(resp, 'id="my_table__action_delete"', 1)
# Row actions
row_actions = self.table.render_row_actions(TEST_DATA[0])
resp = http.HttpResponse(row_actions)
self.assertContains(resp, "<li", 3)
self.assertContains(resp, "my_table__delete__1", 1)
self.assertContains(resp, "my_table__toggle__1", 1)
self.assertContains(resp, "/auth/login/", 1)
self.assertContains(resp, "ajax-modal", 1)
self.assertContains(resp, 'id="my_table__row_1__action_delete"', 1)
# Whole table
resp = http.HttpResponse(self.table.render())
self.assertContains(resp, '<table id="my_table"', 1)
self.assertContains(resp, '<th ', 8)
self.assertContains(resp, 'id="my_table__row__1"', 1)
self.assertContains(resp, 'id="my_table__row__2"', 1)
self.assertContains(resp, 'id="my_table__row__3"', 1)
update_string = "action=row_update&table=my_table&obj_id="
self.assertContains(resp, update_string, 3)
self.assertContains(resp, "data-update-interval", 3)
# Verify no table heading
self.assertNotContains(resp, "<h3 class='table_title'")
# Verify our XSS protection
self.assertContains(resp, '<a href="http://example.com/" '
'data-tip="click for dialog" '
'data-type="modal dialog" '
'class="link-modal">'
'<strong>evil</strong></a>', 1)
# Hidden Title = False shows the table title
self.table._meta.hidden_title = False
resp = http.HttpResponse(self.table.render())
self.assertContains(resp, "<h3 class='table_title'", 1)
# Filter = False hides the search box
self.table._meta.filter = False
table_actions = self.table.render_table_actions()
resp = http.HttpResponse(table_actions)
self.assertContains(resp, "table_search", 0)