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()
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()
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.')
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='关注用户.')
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")