Пример #1
0
	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()
Пример #2
0
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")