コード例 #1
0
def show(username):
    user = User.get_or_none(User.username == username)
    followercount = Following.select().where(Following.user_id == user.id,
                                             Following.approved).count()
    followingcount = Following.select().where(Following.follower_id == user.id,
                                              Following.approved).count()
    is_following = False
    if current_user.is_authenticated:
        find_follow = Following.get_or_none((Following.user_id == user.id) & (
            Following.follower_id == current_user.id) & (Following.approved))
        if find_follow != None:
            is_following = True
    # if planning to show follower and following list, should change the above query and pass the results into template as lists
    # whiteboard note: User.select().join(Following, on=(User.id == Following.follower_id).where(Following.user_id==user.id))

    return render_template('users/profile.html',
                           user=user,
                           is_following=is_following,
                           followingcount=followingcount,
                           followercount=followercount)
コード例 #2
0
ファイル: views.py プロジェクト: suzukisteven/Instagram-Clone
def accept_request(id):
    user = User.get_or_none(id=id)
    followings = Following.update(is_approved = True).where(Following.id == id)
    following = Following.get_by_id(id)
    fan_name = following.fan.user_name
    if followings.execute():
        flash(f"You have approved {fan_name}", "success")
        followings = Following.select().where((Following.idol_id == current_user.id) & (Following.is_approved == False))
        return redirect(url_for('users.request', id=current_user.id, user=user, followings=followings))
    else:
        # Can't think of a scenario where this may happen but handle the scenario anyway.
        flash(f"Could not accept. Please try again.", "danger")
コード例 #3
0
def show(username):
    follow = Following.select().where(
        Following.user_id == current_user.id).where(
            Following.approved == False)

    print(
        "************************************************************************************"
    )
    for f in follow:
        print(f.follower_id)
    print(
        "************************************************************************************"
    )
    check = User.get_or_none(User.username == username)
    if check is not None:
        return render_template("users/profile.html",
                               username=username,
                               picture=check.profile_pic,
                               user=check,
                               current_user=current_user,
                               follow=follow)
    else:
        flash("User does not exist.")
        return redirect(url_for("home"))
コード例 #4
0
 def followings(self):
     from models.following import Following
     return [
         x.idol
         for x in Following.select().where(Following.fan_id == self.id)
     ]
コード例 #5
0
ファイル: views.py プロジェクト: suzukisteven/Instagram-Clone
def show(id):
    user = User.get_or_none(id=id)
    followers = Following.select().where((id==Following.idol_id) & (Following.is_approved == True))
    following = Following.select().where((id==Following.fan_id) & (Following.is_approved == True))
    current_user_follow = Following.get_or_none((current_user.id == Following.fan_id) & (id == Following.idol_id))
    return render_template('images/userprofile.html', user=user, Image=Image, followers=followers, following=following, current_user_follow=current_user_follow)
コード例 #6
0
ファイル: views.py プロジェクト: suzukisteven/Instagram-Clone
def request(id):
    user = User.get_or_none(id=id)
    if current_user == user:
        followings = Following.select().where((Following.idol_id == current_user.id) & (Following.is_approved == False))
        return render_template('request.html', user=user, followings=followings)