Esempio n. 1
0
    def test_is_following_user(self):
        user1 = backend.add_user('username01','photo_url01','weibo_id01')
        user2 = backend.add_user('username02','photo_url02','weibo_id02')

        backend.follow_user(user1['id'],user2['id'])
        ret = backend.is_following_user(user1['id'],user2['id'])
        assert ret == True
Esempio n. 2
0
    def test_is_following_user(self):
        user1 = backend.add_user('username01', 'photo_url01', 'weibo_id01')
        user2 = backend.add_user('username02', 'photo_url02', 'weibo_id02')

        backend.follow_user(user1['id'], user2['id'])
        ret = backend.is_following_user(user1['id'], user2['id'])
        assert ret == True
Esempio n. 3
0
    def get(self,user_id):
        try:
            page = int(request.values.get('page'))
        except:
            page = 1

        limit = 50
        offset = (page - 1) * 50
        followers = backend.get_user_follower(user_id,limit=limit,offset=offset)
        fids = [u['id'] for u in followers]

        curr_user = backend.get_user_by_uid(g.ukey)

        fdict = backend.is_following_user(curr_user['id'],fids)
        for fu in followers:
            fu['follower_count'] = backend.get_user_follower_count(fu['id'])
            fu['is_follow'] = fdict.get(fu['id']) or False
        count = backend.get_user_follower_count(user_id)
        total_page = (count + 49) / 50
        return jsonify(users=followers,page=page,total_page=total_page)
Esempio n. 4
0
    def get(self, user_id):
        user = backend.get_user(user_id)

        user_following_count = backend.get_user_following_count(user_id)
        user_follower_count = backend.get_user_follower_count(user_id)
        user_post_count = backend.get_user_post_count(user_id)
        user_liked_post_count = backend.get_user_liked_post_count(user_id)

        curr_user = backend.get_user_by_uid(g.ukey)

        is_follow = backend.is_following_user(curr_user['id'], user_id)

        pd = {
            'is_follow': is_follow,
            'following_count': user_following_count,
            'follower_count': user_follower_count,
            'post_count': user_post_count,
            'liked_post_count': user_liked_post_count
        }
        user.update(pd)
        return jsonify(**user)
Esempio n. 5
0
    def get(self,user_id):
        user = backend.get_user(user_id)

        user_following_count = backend.get_user_following_count(user_id)
        user_follower_count = backend.get_user_follower_count(user_id)
        user_post_count = backend.get_user_post_count(user_id)
        user_liked_post_count = backend.get_user_liked_post_count(user_id)

        curr_user = backend.get_user_by_uid(g.ukey)

        is_follow = backend.is_following_user(curr_user['id'],user_id)
        
        pd = {
                'is_follow':is_follow,
                'following_count':user_following_count,
                'follower_count':user_follower_count,
                'post_count':user_post_count,
                'liked_post_count':user_liked_post_count
                }
        user.update(pd)
        return jsonify(**user)
Esempio n. 6
0
    def get(self, user_id):
        try:
            page = int(request.values.get('page'))
        except:
            page = 1

        limit = 50
        offset = (page - 1) * 50
        followers = backend.get_user_follower(user_id,
                                              limit=limit,
                                              offset=offset)
        fids = [u['id'] for u in followers]

        curr_user = backend.get_user_by_uid(g.ukey)

        fdict = backend.is_following_user(curr_user['id'], fids)
        for fu in followers:
            fu['follower_count'] = backend.get_user_follower_count(fu['id'])
            fu['is_follow'] = fdict.get(fu['id']) or False
        count = backend.get_user_follower_count(user_id)
        total_page = (count + 49) / 50
        return jsonify(users=followers, page=page, total_page=total_page)
Esempio n. 7
0
 def get(self, user_id_to):
     user_id = authutil.get_user_id(g.ukey)
     ret = backend.is_following_user(user_id, user_id_to)
     return jsonify(is_follow=ret)
Esempio n. 8
0
 def get(self,user_id_to):
     user_id = authutil.get_user_id(g.ukey)
     ret = backend.is_following_user(user_id,user_id_to)
     return jsonify(is_follow=ret)