當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。