def testFollowers(self):
     followers = Interest.followers(1)
     following = False
     for follower in followers:
         if follower.id == 6:
             following = True
     self.assertTrue(following)
Пример #2
0
def followers(id):
    form = InterestFollowersForm(request, url={'id': id})
    if not form.validate():
        return json({'message': 'Validation Failed', 'errors': form.errors}, 422)

    total = Interest.countFollowers(form.id)
    pg = paginate(form, total)

    if total > 0:
        if pg.page_valid:
            data = Interest.followers(form.id, pg.offset, pg.per_page)
        else:
            return json({'message': "This is the end of the list"}, 404)
    else:
        data = []

    return json(dict(followers=data, **pg.info))
Пример #3
0
def followers(id):
    form = InterestFollowersForm(request, url={'id': id})
    if not form.validate():
        return json({
            'message': 'Validation Failed',
            'errors': form.errors
        }, 422)

    total = Interest.countFollowers(form.id)
    pg = paginate(form, total)

    if total > 0:
        if pg.page_valid:
            data = Interest.followers(form.id, pg.offset, pg.per_page)
        else:
            return json({'message': "This is the end of the list"}, 404)
    else:
        data = []

    return json(dict(followers=data, **pg.info))