Пример #1
0
def get_locations():
	user_name = request.GET.get('userName')
	start = int(request.GET.get('start'))
	limit = int(request.GET.get('limit'))

	locations = repo.User(db_session).read(user_name).locations

	#paging by code (discrete values)
	total = len(locations)
	limit = start + limit

	#order by date
	sort_l = sorted(locations, key=lambda n: n.date, reverse=True)

	o = map(lambda l: vo.location(l), sort_l[start:limit])
	return vo.collection(o, total)
Пример #2
0
def read(id):
    l = repo.Location(db_session).read(id)
    o = vo.location(l) if l else ""
    return o
Пример #3
0
def all():
    locations = repo.Location(db_session).all()
    o = map(lambda l: vo.location(l), locations)
    return vo.collection(o, len(o))
Пример #4
0
def get_favlocations():
	user_name = request.GET.get('userName')
	locations = repo.User(db_session).read(user_name).locations
	locations = filter(lambda l: l.favorite, locations)
	o = map(lambda l: vo.location(l), locations)
	return vo.collection(o, len(o))