示例#1
0
def create(idol_id):
    new_idol = FollowerFollowing(fan_id=current_user.id, idol_id=idol_id)
    idol_info = User.get_by_id(idol_id)

    if new_idol.save():
        flash(f"You Just followed {idol_info.name}")
        return redirect(url_for('users.feed'))
    else:
        flash("Oops Something went wrong while following")
        return redirect(url_for('users.feed'))
def accept(fan_id):
    fan = User.get_or_none(User.id == fan_id)
    follow = FollowerFollowing(idol_id=current_user.id, fan_id=fan.id)
    if follow.save():
        flash(f"Accepted {fan.username}. They can now see all your posts.")
        return redirect(url_for('users.profile', id=fan.id))

    else:
        flash("Unsuccessful, guess they're too creepy to accept.")
        return redirect(url_for('home'))
def create(idol_id):
    idol = User.get_or_none(User.id == idol_id)
    follow = FollowerFollowing(fan_id=current_user.id, idol_id=idol.id)
    if follow.save():
        flash(f"Following {idol.username} successful")
        return redirect(url_for('users.profile', id=idol.id))

    else:
        flash("Follow unsuccessful, guess you shouldn't after all")
        return redirect(url_for('home'))
def create(idol_id):

    idol = User.get_or_none(User.id == idol_id)

    if not idol:
        flash(f'No user found with this id', 'error')
        return redirect(url_for('users.index'))

    new_follow = FollowerFollowing(fan_id=current_user.id, idol_id=idol.id)

    if not new_follow.save():
        flash(f"Unable to save this follow", "error")
        return redirect(url_for('users.show', username=idol.name))

    flash('Follow request sent, please wait for approval')
    return redirect(url_for('users.show', username=idol.name))
示例#5
0
def create(idol_id):

    idol = User.get_or_none(User.id == idol_id)

    if not idol:
        flash("User does not exist")
        return redirect(url_for('users.index'))

    f = FollowerFollowing(idol_id=idol.id, fan_id=current_user.id)

    if f.save():
        flash("Successfully followed your idol!")
        return redirect(request.referrer)

    else:
        flash("Go Away!")
        return redirect(url_for('users.index'))
def create(idol_id):

    idol = User.get_or_none(User.id == idol_id)

    if not idol:
        flash('No user found with this ID')
        return redirect(url_for('users.index'))

    new_follow = FollowerFollowing(fan_id=current_user.id, idol_id=idol.id)

    if not new_follow.save():
        flash('Unable to follow this user!')
        return redirect(url_for('users.show', username=idol.name))

    else:
        flash(f'You are now following{idol.name}')
        return redirect(url_for('users.show', username=idol.name))

    flash('Follow request sent! Please wait for approval')
    return redirect(url_for('users.show', username=idol.name))
def create(idols_id):

    idol = User.get_or_none(User.id == idols_id)

    if not idol:
        flash('No user found with this id!')
        return redirect(url_for('users.show_feed'))

    new_follow = FollowerFollowing(
        fans_id=current_user.id,
        idols_id=idol.id
    )

    if not new_follow.save():
        flash('Unable to follow this user!')
        return render_template('followers/new.html', user=idols_id)

    else:
        flash(f'You are now following {idol.username}')
        return redirect(url_for('users.show_feed', username=idol.username))

    flash('Follow request send! Please wait for approval!')
    return redirect(url_for('users.show_feed', username=idol.username))