def index(): form = InterestIndexForm(request) if not form.validate(): return json({'message': 'Validation Failed', 'errors': form.errors}, 422) total = Interest.countAll(form.location, form.radius) pg = paginate(form, total) if total > 0: if pg.page_valid: data = Interest.findAll(form.order, form.location, form.radius, pg.offset, pg.per_page, app.auth.user.id) else: return json({'message': "This is the end of the list"}, 404) else: data = [] return json(dict(interests=data, **pg.info))
def index(): form = InterestIndexForm(request) if not form.validate(): return json({ 'message': 'Validation Failed', 'errors': form.errors }, 422) total = Interest.countAll(form.location, form.radius) pg = paginate(form, total) if total > 0: if pg.page_valid: data = Interest.findAll(form.order, form.location, form.radius, pg.offset, pg.per_page, app.auth.user.id) else: return json({'message': "This is the end of the list"}, 404) else: data = [] return json(dict(interests=data, **pg.info))
def testCountAllAround(self): count = Interest.countAll(location=[-27.86403, -54.4593889], radius=20000) self.assertTrue(is_integer(count))
def testCountAll(self): count = Interest.countAll() self.assertTrue(is_integer(count))