Ejemplo n.º 1
0
def del_following(id):

    target_user = User.query.get(id)
    current_user.un_follow(target_user)
    db.session.commit()  # commit

    flash('Suceess Unfollowing', 'tweet_successful')
    return redirect(url_for('timeline', id=current_user.id))  # to go to route
Ejemplo n.º 2
0
def un_follow_other(username, flag, from_):
    followed_user = User.query.filter_by(username=username).first()
    current_user.un_follow(followed_user)
    flash('已经取消关注啦!')
    if flag == 'from_other':
        return redirect(url_for('auth.display_other', username=from_))
    else:
        return redirect(url_for('auth.display_user'))
Ejemplo n.º 3
0
def un_follow(username):
    user = User.query.filter_by(username=username).first_or_404()
    if not current_user.is_following(user):
        flash('Not follow yet.', 'info')
        return redirect(url_for('.index', username=username))

    current_user.un_follow(user)
    flash('User unfollowed.', 'success')
    return redirect_back()
Ejemplo n.º 4
0
def un_follow(username):
    if not current_user.is_authenticated:
        return jsonify(message='Login required.'), 403

    user = User.query.filter_by(username=username).first_or_404()
    if not current_user.is_following(user):
        return jsonify(message='Not follow yet.'), 400

    current_user.un_follow(user)
    return jsonify(message='Follow canceled.')
Ejemplo n.º 5
0
def unfollow(username):
    user = User.query.filter_by(username=username).first()
    if user is None:
        flash('Invalid user.')
        return redirect(url_for('.index'))
    if not current_user.is_following(user):
        flash('You are not following this user.')
        return redirect(url_for('.user', username=username))
    current_user.un_follow(user)
    flash('You are not following %s.' % username)
    return redirect(url_for('.user', username=username))
Ejemplo n.º 6
0
def unfollow(username):
    user = User.query.filter_by(username=username).first()
    if user is None:
        flash('Invalid user.')
        return redirect(url_for('.index'))
    if not current_user.is_following(user):
        flash('Your are not following this user.')
        return redirect(url_for('.user', username=username))
    current_user.un_follow(user)
    db.session.commit()
    flash('You are not following {} anymore.'.format(username))
    return redirect(url_for('.user', username=username))
Ejemplo n.º 7
0
def un_follow(username):
    users = User.query.filter_by(username=username).first()
    if users is None:
        flash(message='User {} not found.'.format(username))
        return redirect(url_for('index'))
    if users == current_user:
        flash(message='You cannot unfollow yourself!')
        return redirect(url_for('user', username=username))
    current_user.un_follow(users)
    db.session.commit()
    flash(message='You are not following {}.'.format(username))
    return redirect(url_for('user', username=username))
Ejemplo n.º 8
0
def unfollow(username: str):
    user = User.query.filter_by(username=username).first_or_404()
    if current_user.is_following(user):
        current_user.un_follow(user)
    return redirect(url_for('main.profile', username=username))
Ejemplo n.º 9
0
def un_follow(user_id):
    current_user.un_follow(user_id)
    unfollowed = str(id_to_username(user_id))
    flash("You unfollowed {}".format(unfollowed), "good")
    return redirect(request.referrer)