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