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 testFindAllPopularAround(self): objs = Interest.findAll(order_by='popular', location=[-27.86403, -54.4593889], radius=20000) self.assertTrue(len(objs) > 0) for obj in objs: self.assertTrue(isinstance(obj, Interest))
def testFindAllRecentAround(self): objs = Interest.findAll(location=[-27.86403, -54.4593889], radius=20000) self.assertTrue(len(objs) > 0) for obj in objs: self.assertTrue(isinstance(obj, Interest))
def testFindAllOrderByDistance(self): objs = Interest.findAll(order_by='distance', location=[-27.86403, -54.4593889]) self.assertTrue(len(objs) > 0) for obj in objs: self.assertTrue(isinstance(obj, Interest))
def testFindAllPopular(self): objs = Interest.findAll(order_by='popular') self.assertTrue(len(objs) > 0) for obj in objs: self.assertTrue(isinstance(obj, Interest))
def testFindAllRecent(self): objs = Interest.findAll() self.assertTrue(len(objs) > 0) for obj in objs: self.assertTrue(isinstance(obj, Interest))