当前位置: 首页>>代码示例>>Python>>正文


Python OwnerRole.has_role方法代码示例

本文整理汇总了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))
开发者ID:iMMAP,项目名称:onadata,代码行数:16,代码来源:test_permissions.py

示例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))
开发者ID:iMMAP,项目名称:onadata,代码行数:34,代码来源:test_xform_viewset.py

示例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))
开发者ID:onaio,项目名称:onadata,代码行数:25,代码来源:test_permissions.py


注:本文中的onadata.libs.permissions.OwnerRole.has_role方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。