本文整理汇总了Python中onadata.libs.permissions.OwnerRole.has_role方法的典型用法代码示例。如果您正苦于以下问题:Python OwnerRole.has_role方法的具体用法?Python OwnerRole.has_role怎么用?Python OwnerRole.has_role使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类onadata.libs.permissions.OwnerRole
的用法示例。
在下文中一共展示了OwnerRole.has_role方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_reassign_role_owner_to_editor
# 需要导入模块: from onadata.libs.permissions import OwnerRole [as 别名]
# 或者: from onadata.libs.permissions.OwnerRole import has_role [as 别名]
def test_reassign_role_owner_to_editor(self):
self._publish_transportation_form()
alice = self._create_user('alice', 'alice')
self.assertFalse(OwnerRole.has_role(alice, self.xform))
OwnerRole.add(alice, self.xform)
self.assertTrue(OwnerRole.has_role(alice, self.xform))
EditorRole.add(alice, self.xform)
self.assertFalse(OwnerRole.has_role(alice, self.xform))
self.assertTrue(EditorRole.has_role(alice, self.xform))
示例2: test_publish_xlsform
# 需要导入模块: from onadata.libs.permissions import OwnerRole [as 别名]
# 或者: from onadata.libs.permissions.OwnerRole import has_role [as 别名]
def test_publish_xlsform(self):
view = XFormViewSet.as_view({
'post': 'create'
})
data = {
'owner': 'http://testserver/api/v1/users/bob',
'public': False,
'public_data': False,
'description': u'transportation_2011_07_25',
'downloadable': True,
'allows_sms': False,
'encrypted': False,
'sms_id_string': u'transportation_2011_07_25',
'id_string': u'transportation_2011_07_25',
'title': u'transportation_2011_07_25',
'bamboo_dataset': u''
}
path = os.path.join(
settings.PROJECT_ROOT, "apps", "main", "tests", "fixtures",
"transportation", "transportation.xls")
with open(path) as xls_file:
post_data = {'xls_file': xls_file}
request = self.factory.post('/', data=post_data, **self.extra)
response = view(request)
self.assertEqual(response.status_code, 201)
xform = self.user.xforms.all()[0]
data.update({
'url':
'http://testserver/api/v1/forms/%s' % xform.pk
})
self.assertDictContainsSubset(data, response.data)
self.assertTrue(OwnerRole.has_role(self.user, xform))
示例3: test_reassign_role_owner_to_editor
# 需要导入模块: from onadata.libs.permissions import OwnerRole [as 别名]
# 或者: from onadata.libs.permissions.OwnerRole import has_role [as 别名]
def test_reassign_role_owner_to_editor(self):
"""
Test role reassignment owner to editor.
"""
self._publish_transportation_form()
alice = self._create_user('alice', 'alice')
self.assertFalse(OwnerRole.user_has_role(alice, self.xform))
OwnerRole.add(alice, self.xform)
self.assertTrue(OwnerRole.user_has_role(alice, self.xform))
self.assertTrue(
OwnerRole.has_role(perms_for(alice, self.xform), self.xform))
EditorRole.add(alice, self.xform)
self.assertFalse(OwnerRole.user_has_role(alice, self.xform))
self.assertTrue(EditorRole.user_has_role(alice, self.xform))
self.assertFalse(
OwnerRole.has_role(perms_for(alice, self.xform), self.xform))
self.assertTrue(
EditorRole.has_role(perms_for(alice, self.xform), self.xform))