本文整理汇总了Python中API.APIPermissions.get_user_element_permissions方法的典型用法代码示例。如果您正苦于以下问题:Python APIPermissions.get_user_element_permissions方法的具体用法?Python APIPermissions.get_user_element_permissions怎么用?Python APIPermissions.get_user_element_permissions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类API.APIPermissions
的用法示例。
在下文中一共展示了APIPermissions.get_user_element_permissions方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_e_permissions_get_user_element_permissions
# 需要导入模块: from API import APIPermissions [as 别名]
# 或者: from API.APIPermissions import get_user_element_permissions [as 别名]
def test_e_permissions_get_user_element_permissions(self):
user_key = ndb.Key("uk","guep")
element_key = ndb.Key("ek","guep")
ps.add_element_permissions(user_key,element_key,True)
obj = ps.get_user_element_permissions(user_key,element_key)
self.assertEqual(obj.user_key, user_key)
self.assertEqual(obj.element_key, element_key)
self.assertEqual(obj.access, True)
示例2: __check_app_access
# 需要导入模块: from API import APIPermissions [as 别名]
# 或者: from API.APIPermissions import get_user_element_permissions [as 别名]
def __check_app_access(redir = False):
authed_user = auth.get_current_user()
if authed_user is None:
return __unauthed_response(redir)
else:
elem = ps.get_element_key_by_ref('canLogIn')
if elem is not None:
user_key = ps.get_user_key_by_id(authed_user.user_id())
if user_key is not None:
perm = ps.get_user_element_permissions(user_key, elem)
if perm is not None:
if perm.access:
return None
return __not_signed_up_response(redir)
示例3: signup_handler
# 需要导入模块: from API import APIPermissions [as 别名]
# 或者: from API.APIPermissions import get_user_element_permissions [as 别名]
def signup_handler(request):
authed_user = auth.get_current_user()
if authed_user is None:
return __unauthed_response()
user_key = ps.get_user_key_by_id(authed_user.user_id())
if user_key is None:
user_key = ps.add_user(authed_user)
response_part = {
'success' : False
}
try:
file_req = json.loads(request.raw_post_data)
except ValueError:
response_part.update({'error' : 'Invalid request payload.'})
return HttpResponse(json.dumps(response_part), content_type="application/json")
if 'action' not in file_req:
response_part.update({'error' : 'Incomplete request.'})
return HttpResponse(json.dumps(response_part), content_type="application/json")
elem_key = ps.get_element_key_by_ref('canLogIn')
if elem_key is None:
elem_key = ps.add_element('canLogIn')
user_elem = ps.get_user_element_permissions(user_key, elem_key)
if user_elem is not None:
response_part.update({'error' : 'Already signed up.'})
return HttpResponse(json.dumps(response_part), content_type="application/json")
else:
ps.add_element_permissions(user_key, elem_key, True)
response_part.update({'success' : True})
return HttpResponse(json.dumps(response_part), content_type="application/json")
示例4: test_e_permissions_revoke_user_element_permissions
# 需要导入模块: from API import APIPermissions [as 别名]
# 或者: from API.APIPermissions import get_user_element_permissions [as 别名]
def test_e_permissions_revoke_user_element_permissions(self):
user_key = ndb.Key("uk","ruep")
element_key = ndb.Key("ek","ruep")
ps.add_element_permissions(user_key,element_key,True)
ps.revoke_user_element_permissions(user_key,element_key)
self.assertIsNone(ps.get_user_element_permissions(user_key,element_key))