Example #1
0
def search_workspace():
	user_name = request.GET.get('userName')
	start = int(request.GET.get('start'))
	limit = int(request.GET.get('limit'))
	name_pattern = request.GET.get('namePattern')
	name_position = request.GET.get('namePosition')
	user_pattern = request.GET.get('userPattern')
	user_position = request.GET.get('userPosition')
	
	workspaces = repo.User(db_session).read(user_name).workspaces
	
	#filter owner
	workspaces = util.collection_filter(user_position, user_pattern, 'user_name', workspaces)
	
	#filter name
	workspaces = util.collection_filter(name_position, name_pattern, 'name', workspaces)

	#sort
	workspaces = sorted(workspaces, key=lambda l: l.name)
	
	total = len(workspaces)
	limit = start + limit
	
	o = map(lambda ws: vo.workspace(ws), workspaces[start:limit])
	return vo.collection(o, total)
Example #2
0
def search_layer():
	user_name = request.GET.get('userName')
	start = int(request.GET.get('start'))
	limit = int(request.GET.get('limit'))
	pattern = request.GET.get('pattern')
	position = request.GET.get('position')
	type = request.GET.get('type')

	nodes = repo.User(db_session).read(user_name).nodes
	layers = map(lambda n: n.layer,filter(lambda n: n.leaf, nodes))

	#filter type
	if(type != '%'):
		layers = filter(lambda l: l.type == type, layers)
	
	#filter title
	layers = util.collection_filter(position, pattern, 'title', layers)

	#sort
	layers = sorted(layers, key=lambda l: l.title)
	
	total = len(layers)
	limit = start + limit

	o = map(lambda l: vo.layer(l), layers[start:limit])
	return vo.collection(o, total)