本文整理汇总了Python中API.APIPermissions.get_file_permissions_list方法的典型用法代码示例。如果您正苦于以下问题:Python APIPermissions.get_file_permissions_list方法的具体用法?Python APIPermissions.get_file_permissions_list怎么用?Python APIPermissions.get_file_permissions_list使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类API.APIPermissions
的用法示例。
在下文中一共展示了APIPermissions.get_file_permissions_list方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_permissions_revoke_all_by_file_key
# 需要导入模块: from API import APIPermissions [as 别名]
# 或者: from API.APIPermissions import get_file_permissions_list [as 别名]
def test_permissions_revoke_all_by_file_key(self):
fk = ndb.Key("fk","rafk")
ps.add_file_permissions(fk,ndb.Key("uk","rafk1"),Permissions(True,True,True))
ps.add_file_permissions(fk,ndb.Key("uk","rafk2"),Permissions(True,True,True))
ps.add_file_permissions(fk,ndb.Key("uk","rafk3"),Permissions(True,True,True))
ps.revoke_all_by_file_key(fk)
with self.assertRaises(StopIteration):
ps.get_file_permissions_list(fk).next()
示例2: test_permissions_get_user_permissions_list
# 需要导入模块: from API import APIPermissions [as 别名]
# 或者: from API.APIPermissions import get_file_permissions_list [as 别名]
def test_permissions_get_user_permissions_list(self):
uk = ndb.Key("uk","gupl")
ps.add_file_permissions(ndb.Key("fk","gupl1"),uk,Permissions(True,True,True))
ps.add_file_permissions(ndb.Key("fk","gupl2"),uk,Permissions(True,True,True))
ps.add_file_permissions(ndb.Key("fk","gupl3"),uk,Permissions(True,True,True))
permissions = ps.get_file_permissions_list(uk)
for permission in permissions:
self.assertEqual(permission.user_key, uk)
示例3: test_permissions_get_file_permissions_list
# 需要导入模块: from API import APIPermissions [as 别名]
# 或者: from API.APIPermissions import get_file_permissions_list [as 别名]
def test_permissions_get_file_permissions_list(self):
fk = ndb.Key("fk","gfpl")
ps.add_file_permissions(fk,ndb.Key("uk","gfpl1"),Permissions(True,True,True))
ps.add_file_permissions(fk,ndb.Key("uk","gfpl2"),Permissions(True,True,True))
ps.add_file_permissions(fk,ndb.Key("uk","gfpl3"),Permissions(True,True,True))
permissions = ps.get_file_permissions_list(fk)
for permission in permissions:
self.assertEqual(permission.file_key, fk)
示例4: file_permissions_json
# 需要导入模块: from API import APIPermissions [as 别名]
# 或者: from API.APIPermissions import get_file_permissions_list [as 别名]
def file_permissions_json(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())
json_response = {
'success' : False,
'users' : []
}
try:
list_req = json.loads(request.raw_post_data)
except ValueError:
json_response.update({'error' : 'Invalid request payload.'})
return HttpResponse(json.dumps(json_response), content_type="application/json")
if 'filename' not in list_req:
json_response.update({'error' : 'Incomplete request.'})
return HttpResponse(json.dumps(json_response), content_type="application/json")
filename = list_req['filename']
file_entry = ps.get_file_by_name(DATA_BUCKET + '/' + filename)
if file_entry is None:
json_response.update( { 'error' : 'File does not exist.' } )
return HttpResponse(json.dumps(json_response), content_type="application/json")
fp_entry = ps.get_user_file_permissions(file_entry.key, user_key)
if fp_entry is None:
json_response.update( { 'error' : 'Permission denied.' } )
return HttpResponse(json.dumps(json_response), content_type="application/json")
permissions_list = ps.get_file_permissions_list(file_entry.key)
if permissions_list is None:
json_response.update( { 'error' : 'Permission could not be retrieved.' } )
return HttpResponse(json.dumps(json_response), content_type="application/json")
for perm in permissions_list:
new_perm = {}
user = ps.get_user_by_key(perm.user_key)
if user is not None:
nickname = user.nickname()
email = user.email()
user_found = True
else:
nickname = 'Unknown'
email = 'unknown'
user_found = False
new_perm.update( {
'nickname' : nickname,
'userFound' : user_found,
'email' : email,
'isMe' : (perm.user_key == user_key),
'permissions' : {
'read' : perm.read,
'write' : perm.write,
'fullControl' : perm.full_control
}
} )
json_response['users'].append(new_perm)
json_response.update({ 'success' : True })
return HttpResponse(json.dumps(json_response), content_type="application/json")