コード例 #1
0
ファイル: interests.py プロジェクト: mayconbordin/boardhood
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))
コード例 #2
0
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))
コード例 #3
0
    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))
コード例 #4
0
    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))
コード例 #5
0
    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))
コード例 #6
0
    def testFindAllPopular(self):
        objs = Interest.findAll(order_by='popular')
        self.assertTrue(len(objs) > 0)

        for obj in objs:
            self.assertTrue(isinstance(obj, Interest))
コード例 #7
0
    def testFindAllRecent(self):
        objs = Interest.findAll()
        self.assertTrue(len(objs) > 0)

        for obj in objs:
            self.assertTrue(isinstance(obj, Interest))