當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。