本文整理汇总了Python中API.APIPermissions.add_file_permissions方法的典型用法代码示例。如果您正苦于以下问题:Python APIPermissions.add_file_permissions方法的具体用法?Python APIPermissions.add_file_permissions怎么用?Python APIPermissions.add_file_permissions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类API.APIPermissions
的用法示例。
在下文中一共展示了APIPermissions.add_file_permissions方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_permissions_get_user_file_permissions
# 需要导入模块: from API import APIPermissions [as 别名]
# 或者: from API.APIPermissions import add_file_permissions [as 别名]
def test_permissions_get_user_file_permissions(self):
user_key = ndb.Key("uk","gufp")
file_key = ndb.Key("fk","gufp")
perms = Permissions(True,True,True)
ps.add_file_permissions(file_key,user_key,perms)
obj = ps.get_user_file_permissions(file_key,user_key)
self.assertEqual(obj.user_key, user_key)
self.assertEqual(obj.file_key, file_key)
self.assertEqual(obj.read, perms.read)
self.assertEqual(obj.write, perms.write)
self.assertEqual(obj.full_control, perms.full_control)
示例2: generate_gating_feedback
# 需要导入模块: from API import APIPermissions [as 别名]
# 或者: from API.APIPermissions import add_file_permissions [as 别名]
def generate_gating_feedback(status, message, new_graph_name = None, existing_name = None, new_axis_a = "FSC-A", new_axis_b = "SSC-A"):
if new_graph_name is not None:
## Authenticate and get user
authed_user = auth.get_current_user()
user_key = ps.get_user_key_by_id(authed_user.user_id())
## Get previous file permissions.
previous_file = ps.get_file_by_name(DATA_BUCKET + existing_name)
previous_permissions = ps.get_user_file_permissions(previous_file.key, user_key)
if isinstance(new_graph_name, list):
new_graph_names = new_graph_name
else:
new_graph_names = [new_graph_name]
# Overwrite new_graph_name for return dictionary
new_graph_name = new_graph_names[0]
logging.info(new_graph_name)
logging.info(new_graph_names)
for new_name in new_graph_names:
new_file = FileInfo(file_name = DATA_BUCKET + new_name,
owner_key = user_key,
friendly_name = previous_file.friendly_name + '-gate',
prev_file_key = previous_file.key,
axis_a = new_axis_a,
axis_b = new_axis_b )
file_key = ps.add_file(new_file)
ps.add_file_permissions(file_key,
user_key,
Permissions (
previous_permissions.read,
previous_permissions.write,
previous_permissions.full_control
),
previous_permissions.colour,
False)
return {
'status': status,
'message': message,
'url': reverse('get_graph', args=[new_graph_name]),
'graphName' : new_graph_name
}
示例3: test_permissions_modify_file_permissions_by_key
# 需要导入模块: from API import APIPermissions [as 别名]
# 或者: from API.APIPermissions import add_file_permissions [as 别名]
def test_permissions_modify_file_permissions_by_key(self):
permission = Permissions(True,True,True)
key = ps.add_file_permissions(ndb.Key("fk","mfpk"),ndb.Key("uk","mfpk"),permission)
new_permissions = Permissions(False,False,False)
ps.modify_file_permissions_by_key(key, new_permissions)
retrieved = ps.get_permissions_by_key(key)
self.assertEqual(new_permissions.read, retrieved.read)
self.assertEqual(new_permissions.write, retrieved.write)
self.assertEqual(new_permissions.full_control, retrieved.full_control)
示例4: test_permissions_revoke_all_by_user_key
# 需要导入模块: from API import APIPermissions [as 别名]
# 或者: from API.APIPermissions import add_file_permissions [as 别名]
def test_permissions_revoke_all_by_user_key(self):
uk = ndb.Key("uk","rauk")
ps.add_file_permissions(ndb.Key("fk","rauk1"),uk,Permissions(True,True,True))
ps.add_file_permissions(ndb.Key("fk","rauk1"),uk,Permissions(True,True,True))
ps.add_file_permissions(ndb.Key("fk","rauk1"),uk,Permissions(True,True,True))
ps.revoke_all_by_user_key(uk)
with self.assertRaises(StopIteration):
ps.get_user_permissions_list(uk).next()
示例5: test_permissions_revoke_all_by_file_key
# 需要导入模块: from API import APIPermissions [as 别名]
# 或者: from API.APIPermissions import add_file_permissions [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()
示例6: test_permissions_get_user_permissions_list
# 需要导入模块: from API import APIPermissions [as 别名]
# 或者: from API.APIPermissions import add_file_permissions [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)
示例7: test_permissions_get_file_permissions_list
# 需要导入模块: from API import APIPermissions [as 别名]
# 或者: from API.APIPermissions import add_file_permissions [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)
示例8: test_permissions_get_user_file_permissions_key
# 需要导入模块: from API import APIPermissions [as 别名]
# 或者: from API.APIPermissions import add_file_permissions [as 别名]
def test_permissions_get_user_file_permissions_key(self):
user_key = ndb.Key("uk","gpbk")
file_key = ndb.Key("fk","gpbk")
perms = Permissions(True,True,True)
key = ps.add_file_permissions(file_key,user_key,perms)
self.assertEqual(key,ps.get_user_file_permissions_key(file_key,user_key))
示例9: test_permissions_revoke_user_file_permissions
# 需要导入模块: from API import APIPermissions [as 别名]
# 或者: from API.APIPermissions import add_file_permissions [as 别名]
def test_permissions_revoke_user_file_permissions(self):
user_key = ndb.Key("uk","rufp")
file_key = ndb.Key("fk","rufp")
ps.add_file_permissions(file_key,user_key,Permissions(True,True,True))
ps.revoke_user_file_permissions(file_key,user_key)
self.assertIsNone(ps.get_user_file_permissions(file_key,user_key))
示例10: test_permissions_revoke_permissions_by_key
# 需要导入模块: from API import APIPermissions [as 别名]
# 或者: from API.APIPermissions import add_file_permissions [as 别名]
def test_permissions_revoke_permissions_by_key(self):
key = ps.add_file_permissions(ndb.Key("fk","rpbk"),ndb.Key("uk","rpbk"),Permissions(True,True,True))
ps.revoke_permissions_by_key(key)
self.assertIsNone(ps.get_permissions_by_key(key))
示例11: test_permissions_add_file_permissions
# 需要导入模块: from API import APIPermissions [as 别名]
# 或者: from API.APIPermissions import add_file_permissions [as 别名]
def test_permissions_add_file_permissions(self):
permission = Permissions(True,True,False)
ret = ps.add_file_permissions(ndb.Key("fk","afp"),ndb.Key("uk","afp"),permission)
self.assertTrue(isinstance(ret, ndb.Key))
示例12: file_permissions_edit
# 需要导入模块: from API import APIPermissions [as 别名]
# 或者: from API.APIPermissions import add_file_permissions [as 别名]
def file_permissions_edit(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
}
action_responses = []
try:
permissions_request = 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 ( ('actions' not in permissions_request)
or ('filename' not in permissions_request)):
json_response.update( {'error' : 'Incomplete request.'} )
return HttpResponse(json.dumps(json_response), content_type="application/json")
filename = permissions_request['filename']
actions = permissions_request['actions']
if not isinstance(actions, list):
json_response.update( {'error' : 'Actions list is not a list.'} )
return HttpResponse(json.dumps(json_response), content_type="application/json")
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")
res = []
for action in actions:
if ( ('action' in action) # Can't do anything without an action name
and ('userEmail' in action)): # Or a user for that matter
user_email = action['userEmail']
action_name = action['action']
response_part = {
'success' : False,
'action' : action,
'userEmail' : user_email
}
share_user_key = ps.get_user_key_by_email(user_email)
if share_user_key is None:
response_part.update( { 'error' : 'User not found.' } )
action_responses.append(response_part)
continue
else:
response_part = {
'success' : False,
'error' : 'Incomplete request.'
}
continue
edit_permissions = ps.get_user_file_permissions(file_entry.key, share_user_key)
if action_name == 'dropUser':
if edit_permissions is None:
response_part.update( { 'error' : 'User does not have permissions for this file.' } )
else:
remove_action = ps.revoke_permissions_by_key(edit_permissions.key)
if remove_action:
response_part.update( { 'success' : True } )
else:
response_part.update( { 'error' : 'Could not revoke permissions.' } )
elif action_name == 'addUser':
if edit_permissions is None:
if ( ('read' not in action)
or ('write' not in action)
or ('fullControl' not in action)):
response_part.update( { 'error' : 'Incomplete action - permissions not specified.'} )
else:
add_action = ps.add_file_permissions(file_entry.key, share_user_key,
Permissions(
action['read'],
action['write'],
action['fullControl']
) )
if add_action:
response_part.update( { 'success' : True } )
else:
response_part.update( { 'error' : 'Could not add user to file.' } )
else:
#.........这里部分代码省略.........