本文整理汇总了Python中openedx.core.djangoapps.api_admin.models.ApiAccessRequest.has_api_access方法的典型用法代码示例。如果您正苦于以下问题:Python ApiAccessRequest.has_api_access方法的具体用法?Python ApiAccessRequest.has_api_access怎么用?Python ApiAccessRequest.has_api_access使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openedx.core.djangoapps.api_admin.models.ApiAccessRequest
的用法示例。
在下文中一共展示了ApiAccessRequest.has_api_access方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: wrapped_view
# 需要导入模块: from openedx.core.djangoapps.api_admin.models import ApiAccessRequest [as 别名]
# 或者: from openedx.core.djangoapps.api_admin.models.ApiAccessRequest import has_api_access [as 别名]
def wrapped_view(view_obj, *args, **kwargs):
"""Wrapper for the view function."""
if ApiAccessRequest.has_api_access(args[0].user):
return view_func(view_obj, *args, **kwargs)
return redirect(reverse('api_admin:api-request'))
示例2: test_has_access
# 需要导入模块: from openedx.core.djangoapps.api_admin.models import ApiAccessRequest [as 别名]
# 或者: from openedx.core.djangoapps.api_admin.models.ApiAccessRequest import has_api_access [as 别名]
def test_has_access(self, status, should_have_access):
self.request.status = status
self.request.save() # pylint: disable=no-member
self.assertEqual(ApiAccessRequest.has_api_access(self.user), should_have_access)
示例3: test_default_status
# 需要导入模块: from openedx.core.djangoapps.api_admin.models import ApiAccessRequest [as 别名]
# 或者: from openedx.core.djangoapps.api_admin.models.ApiAccessRequest import has_api_access [as 别名]
def test_default_status(self):
self.assertEqual(self.request.status, ApiAccessRequest.PENDING)
self.assertFalse(ApiAccessRequest.has_api_access(self.user))
示例4: test_nonexistent_request
# 需要导入模块: from openedx.core.djangoapps.api_admin.models import ApiAccessRequest [as 别名]
# 或者: from openedx.core.djangoapps.api_admin.models.ApiAccessRequest import has_api_access [as 别名]
def test_nonexistent_request(self):
"""Test that users who have not requested API access do not get it."""
other_user = UserFactory()
self.assertFalse(ApiAccessRequest.has_api_access(other_user))
示例5: test_has_access
# 需要导入模块: from openedx.core.djangoapps.api_admin.models import ApiAccessRequest [as 别名]
# 或者: from openedx.core.djangoapps.api_admin.models.ApiAccessRequest import has_api_access [as 别名]
def test_has_access(self, status, should_have_access):
self.request.status = status
self.request.save()
self.assertEqual(ApiAccessRequest.has_api_access(self.user), should_have_access)