コード例 #1
0
ファイル: user.py プロジェクト: wangtianxing1010/Album-Wall
def follow(username):
    user = User.query.filter_by(username=username).first_or_404()
    if current_user.is_following(user):
        flash("Already followed", 'warning')
        return redirect(url_for('.index', username=username))
    current_user.follow(user)
    flash("User followed", 'success')
    if user.receive_follow_notifications:
        push_follow_notification(follower=current_user, receiver=user)
    return redirect_back()
コード例 #2
0
ファイル: user.py プロジェクト: wk-955/flask-project-album
def follow(username):
    user = User.query.filter_by(username=username).first_or_404()
    if current_user.is_following(user):
        flash('早已关注.', 'info')
        return redirect(url_for('.index', username=username))

    current_user.follow(user)
    flash('用户已关注', 'success')
    if user.receive_follow_notification:
        push_follow_notification(follower=current_user, receiver=user)
    return redirect_back()
コード例 #3
0
def follow(username):
    if not current_user.is_authenticated:
        return jsonify(message='Login required.'), 403
    if not current_user.confirmed:
        return jsonify(message='Confirm account required.'), 400
    if not current_user.can('FOLLOW'):
        return jsonify(message='No permission'), 403

    user = User.query.filter_by(username=username).first_or_404()
    if current_user.is_following(user):
        return jsonify(message='Already followed.'), 400

    current_user.follow(user)
    push_follow_notification(follower=current_user, receiver=user)
    return jsonify(message='User followed.')
コード例 #4
0
def follow(username):
    if not current_user.is_authenticated:
        return jsonify(message='需要登录.'), 403
    if not current_user.confirmed:
        return jsonify(message='需要确认帐户.'), 400
    if not current_user.can('COLLECT'):
        return jsonify(message='不允许.'), 403

    user = User.query.filter_by(username=username).first_or_404()
    if current_user.if_following(user):
        return jsonify(message='早已关注.'), 400

    current_user.follow(user)
    if user.receive_follow_notification:
        push_follow_notification(follower=current_user, receiver=user)
    return jsonify(message='关注用户.')
コード例 #5
0
def follow(username):
    if not current_user.is_authenticated:
        return jsonify(message="Login required"), 403

    if not current_user.confirmed:
        return jsonify(message='Account confirmation required'), 400

    if not current_user.can("FOLLOW"):
        return jsonify(message='No permission'), 403

    user = User.query.filter_by(username=username).first_or_404()
    if current_user.is_following(user):
        return jsonify(message='Already followed'), 400

    current_user.follow(user)
    if user.receive_collect_notifications:
        push_follow_notification(follower=current_user, receiver=user)
    return jsonify(message="User followed")