當前位置: 首頁>>代碼示例>>Python>>正文


Python APIPermissions.get_file_permissions_list方法代碼示例

本文整理匯總了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()
開發者ID:Keesaco,項目名稱:KeesaFlo,代碼行數:11,代碼來源:TestAPIPermissions.py

示例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)
開發者ID:Keesaco,項目名稱:KeesaFlo,代碼行數:12,代碼來源:TestAPIPermissions.py

示例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)
開發者ID:Keesaco,項目名稱:KeesaFlo,代碼行數:12,代碼來源:TestAPIPermissions.py

示例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")
開發者ID:Keesaco,項目名稱:KeesaFlo,代碼行數:69,代碼來源:views.py


注:本文中的API.APIPermissions.get_file_permissions_list方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。