예제 #1
0
def follow(target_id):
    self_id = session.get('user_id')
    target = User.find_by_id(target_id)
    tasks = User.retrieve_published_tasks(target_id)
    if self_id and target:
        User.follow_user(self_id, target_id)
        return redirect(url_for('show_user', user_id=target_id))
    return redirect(url_for('index'))
예제 #2
0
def show_user(user_id):
    self_id = session.get('user_id')
    user = User.find_by_id(user_id)
    friends_2_hop = User.retrieve_2_hop_friends(user_id)
    user_follower_count = User.fetch_follower_count(user_id)
    user_following_count = User.fetch_following_count(user_id)
    score_as_helper = User.fetch_score_as_helper(user_id)
    score_as_helpee = User.fetch_score_as_helpee(user_id)
    if user:
        if self_id:
            tasks = User.retrieve_published_tasks(user_id, self_id)
            adopted_tasks = User.retrieve_adopted_tasks(user_id, self_id)
            if User.is_following(self_id, user_id):
                return render_template('user_page.html', user_name=user[1], tasks=tasks, user_id=user_id, is_following = True, adopted_tasks=adopted_tasks, user_portrait_url = user[6], user_following_count=user_following_count, user_follower_count = user_follower_count, score_as_helper = score_as_helper[0], score_as_helpee = score_as_helpee[0])
            else:
                return render_template('user_page.html', user_name=user[1], tasks=tasks, user_id=user_id, is_following = False, friends_2_hop=friends_2_hop, user_portrait_url = user[6], user_following_count=user_following_count, user_follower_count = user_follower_count, score_as_helper = score_as_helper[0], score_as_helpee = score_as_helpee[0])
        else:
            tasks = User.retrieve_published_tasks(user_id)
            return render_template('user_page.html', user_name=user[1], tasks=tasks, user_id=user_id, user_portrait_url = user[6], user_following_count=user_following_count, user_follower_count = user_follower_count, score_as_helper = score_as_helper[0], score_as_helpee = score_as_helpee[0])
    else:
        return redirect(url_for('index'))