def follow(username): user = User.query.filter_by(username=username).first_or_404() if current_user.is_following(user): flash('Already followed', 'info') return redirect(url_for('user.index', username=username)) current_user.follow(user) flash('User followed', 'success') if user.receive_follow_notification: 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("Already followed.", "info") return redirect(url_for("user.index", username=username)) current_user.follow(user) flash("User followed.", "success") if current_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 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_notification: push_follow_notification(follower=current_user, receiver=user) return jsonify(message='User followed.')
def follow(username): user = User.query.filter_by(username=username).first_or_404() if current_user.is_following(user): flash('Already followed.', 'info') return redirect(url_for('.index', username=username)) current_user.follow(user) flash('User followed.', 'success') if user.receive_follow_notification: push_follow_notification( follower=current_user, receiver=user ) #这个函数里面实现了一个向被关注者推送提醒的功能,它跟这个函数里始终是current user的主体有区别,要注意 return redirect_back()
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('FOLLOW'): return jsonify(message='没有权限!'), 403 user = User.query.filter_by(username=username).first_or_404() if current_user.is_following(user): return jsonify(message='已经关注了。'), 400 current_user.follow(user) 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='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="Login requeired."), 403 if not current_user.confirmed: return jsonify(message="Confirmed 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) if current_user.receive_collect_notification: push_follow_notification(follow=current_user, receiver=user) return jsonify(message="User followed.")
def follow(username): """ 关注其他用户 :param username: 被关注者的用户名 """ logger.info('url = ' + str(request.url)) # 被关注者的实例对象 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()