当前位置: 首页>>代码示例>>Python>>正文


Python API.APIPermissions类代码示例

本文整理汇总了Python中API.APIPermissions的典型用法代码示例。如果您正苦于以下问题:Python APIPermissions类的具体用法?Python APIPermissions怎么用?Python APIPermissions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了APIPermissions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: file_list_json

def file_list_json(request):
	app_access = __check_app_access()
	if app_access is not None:
		return app_access
	
	authed_user = auth.get_current_user()
	user_key = ps.get_user_key_by_id(authed_user.user_id())
	#TODO: This shouldn't be here - a generic method in APIPermissions would be nice.


	# 'your files'
	file_list = []

	lst = ps.get_user_permissions_list(user_key)
	temp_group = []
	if lst is not None:
		for perm in lst:
			list_entry = {}
			file_entry = ps.get_file_by_key(perm.file_key)
			if file_entry is not None:
				
				temp_file = ds.get_file_info(file_entry.file_name)
				if temp_file is None:
					continue
				
				list_entry.update({ 'permissions' 	: 'yes',
									'friendlyName'	: file_entry.friendly_name,
									'colour'		: perm.colour,
									'starred'		: perm.starred
								} )
		
				temp_file.filename = temp_file.filename.rpartition('/')[2]
				list_entry.update( {	'filename' 		: temp_file.filename,
										'size' 			: temp_file.st_size,
								  		'hash' 			: temp_file.etag,
								  		'timestamp' 	: temp_file.st_ctime
								  })
				temp_group.append(list_entry)


	if len(temp_group) > 0:
		file_list.append({	'catagory' 	: 'owned',
							'heading' 	: 'Your Files',
						 	'type'		: 'files',
							'data' 		: temp_group })
						
	if len(file_list) == 0:
		file_list.append({	'catagory' 	: 'notice',
						 	'type'		: 'html',
						 
						 	# TODO: move this line out
						 	'data'		: '<a data-toggle="modal" data-target="#uploadModal" class="list-group-item">No files - Click here to upload one</a>'
							})


	return HttpResponse(json.dumps(file_list), content_type="application/json")
开发者ID:Keesaco,项目名称:KeesaFlo,代码行数:56,代码来源:views.py

示例2: test_user_get_user_key_by_id

	def test_user_get_user_key_by_id(self):
		usr = User('[email protected]')
		usr.set_nickname('Somebodyguki')
		usr.set_user_id('SomeUserid1234guki')
		key = ps.add_user(usr)

		self.assertEqual(key,ps.get_user_key_by_id("SomeUserid1234guki"))
开发者ID:Keesaco,项目名称:KeesaFlo,代码行数:7,代码来源:TestAPIPermissions.py

示例3: test_e_permissions_modify_user_element_permissions

	def test_e_permissions_modify_user_element_permissions(self):
		key = ps.add_element_permissions(ndb.Key("uk","muep"),ndb.Key("ek","muep"),True)

		ps.modify_user_element_permissions(ndb.Key("uk","muep"),ndb.Key("ek","muep"), False)
		retrieved = ps.get_element_permissions_by_key(key)

		self.assertFalse(retrieved.access)
开发者ID:Keesaco,项目名称:KeesaFlo,代码行数:7,代码来源:TestAPIPermissions.py

示例4: test_user_get_user_by_key_succeed

	def test_user_get_user_by_key_succeed(self):
		usr = User('[email protected]')
		usr.set_nickname('Somebodyguks')
		usr.set_user_id('SomeUserid1234guks')
		key = ps.add_user(usr)

		self.assertEqual(ps.get_user_by_key(key).email(), usr.email())
开发者ID:Keesaco,项目名称:KeesaFlo,代码行数:7,代码来源:TestAPIPermissions.py

示例5: test_user_remove_user_by_key_succeed

	def test_user_remove_user_by_key_succeed(self):
		usr = User('[email protected]')
		usr.set_nickname('Somebodyruks')
		usr.set_user_id('SomeUserid1234ruks')
		ukey = ps.add_user(usr)

		self.assertTrue(ps.remove_user_by_key(ukey))
开发者ID:Keesaco,项目名称:KeesaFlo,代码行数:7,代码来源:TestAPIPermissions.py

示例6: test_file_rename_file_by_key_success

	def test_file_rename_file_by_key_success(self):
		key = ps.add_file( FileInfo("testFilernfks",ndb.Key("someKey","rnfks") ) )

		self.assertTrue(ps.rename_file_by_key(key,"testFilernfks2"))

		fileobj = ps.get_file_by_key(key)

		self.assertEqual(fileobj.file_name,"testFilernfks2")
开发者ID:Keesaco,项目名称:KeesaFlo,代码行数:8,代码来源:TestAPIPermissions.py

示例7: test_permissions_revoke_all_by_user_key

	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()
开发者ID:Keesaco,项目名称:KeesaFlo,代码行数:9,代码来源:TestAPIPermissions.py

示例8: test_e_permissions_revoke_element_permissions_element_key

	def test_e_permissions_revoke_element_permissions_element_key(self):
		ek = ndb.Key("ek","repek")
		ps.add_element_permissions(ndb.Key("uk","repek1"),ek,True)
		ps.add_element_permissions(ndb.Key("uk","repek2"),ek,True)
		ps.add_element_permissions(ndb.Key("uk","repek3"),ek,True)

		ps.revoke_element_permissions_element_key(ek)
		with self.assertRaises(StopIteration):
			ps.get_element_permissions_by_element_key(ek).next()
开发者ID:Keesaco,项目名称:KeesaFlo,代码行数:9,代码来源:TestAPIPermissions.py

示例9: test_e_permissions_revoke_element_permissions_user_key

	def test_e_permissions_revoke_element_permissions_user_key(self):
		uk = ndb.Key("uk","repuk")
		ps.add_element_permissions(uk,ndb.Key("ek","repuk1"),True)
		ps.add_element_permissions(uk,ndb.Key("ek","repuk1"),True)
		ps.add_element_permissions(uk,ndb.Key("ek","repuk1"),True)

		ps.revoke_element_permissions_user_key(uk)
		with self.assertRaises(StopIteration):
			ps.get_element_permissions_by_user_key(uk).next()
开发者ID:Keesaco,项目名称:KeesaFlo,代码行数:9,代码来源:TestAPIPermissions.py

示例10: test_permissions_revoke_all_by_file_key

	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,代码行数:9,代码来源:TestAPIPermissions.py

示例11: test_e_permissions_get_element_permissions_by_key

	def test_e_permissions_get_element_permissions_by_key(self):
		user_key = ndb.Key("uk","gepk")
		element_key = ndb.Key("ek","gepk")
		key = ps.add_element_permissions(user_key,element_key,True)

		obj = ps.get_element_permissions_by_key(key)

		self.assertEqual(obj.user_key, user_key)
		self.assertEqual(obj.element_key, element_key)
		self.assertEqual(obj.access, True)
开发者ID:Keesaco,项目名称:KeesaFlo,代码行数:10,代码来源:TestAPIPermissions.py

示例12: test_permissions_modify_file_permissions_by_key

	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)
开发者ID:Keesaco,项目名称:KeesaFlo,代码行数:11,代码来源:TestAPIPermissions.py

示例13: test_user_modify_user_by_id_succeed

	def test_user_modify_user_by_id_succeed(self):
		usr = User('[email protected]')
		usr.set_nickname('Somebodymids')
		usr.set_user_id('SomeUserid1234mids')
		ps.add_user(usr)

		newusr = User('[email protected]')
		newusr.set_nickname('SomebodyElsemids')
		newusr.set_user_id('SomeUotherId3878mids')
		key = ps.modify_user_by_id('SomeUserid1234mids',newusr)

		self.assertEqual(ps.get_user_by_key(key).email(), newusr.email())
开发者ID:Keesaco,项目名称:KeesaFlo,代码行数:12,代码来源:TestAPIPermissions.py

示例14: test_permissions_get_permissions_by_key

	def test_permissions_get_permissions_by_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)

		obj = ps.get_permissions_by_key(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)
开发者ID:Keesaco,项目名称:KeesaFlo,代码行数:12,代码来源:TestAPIPermissions.py

示例15: test_file_get_files_by_owner_key_sucess

	def test_file_get_files_by_owner_key_sucess(self):
		ps.add_file( FileInfo("testFile1",ndb.Key("someKey","gfuks") ) )
		ps.add_file( FileInfo("testFile2",ndb.Key("someKey","gfuks") ) )
		ps.add_file( FileInfo("testFile3",ndb.Key("someKey","gfuks") ) )
		ps.add_file( FileInfo("testFile4",ndb.Key("someKey","gfuks") ) )
		
		iterate = ps.get_file_by_owner_key(ndb.Key("someKey","gfuks"))

		for fileobj in iterate:
			self.assertEqual(fileobj.owner_key, ndb.Key("someKey","gfuks"))
开发者ID:Keesaco,项目名称:KeesaFlo,代码行数:10,代码来源:TestAPIPermissions.py


注:本文中的API.APIPermissions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。