我们从Python开源项目中,提取了以下21个代码示例,用于说明如何使用flask_login.current_user.is_following()。
def follow(username): """????""" user = User.query.filter_by(username=username).first() if user is None: return jsonify(error=constant.INVALID_USER) if user == current_user: return jsonify(constant.CANNOT_CON_MYSELF) if current_user.is_following(user): return jsonify(error=constant.ALREADY_CON) try: current_user.follow(user) except Exception as e: return jsonify(constant.FAIL) current_user.notify_follower(user.id, "follow_user") return jsonify(error="")
def follow(username): user = User.query.filter_by(username=username).first() if user is None: flash('Invalid user.') return redirect(url_for('.index')) if current_user.is_following(user): flash('You are already following this user.') return redirect(url_for('.user', username=username)) current_user.follow(user) flash('You are now following %s.' % username) return redirect(url_for('.user', username=username))
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.unfollow(user) flash('You are not following %s anymore.' % username) return redirect(url_for('.user', username=username))
def follow(nickname): user = User.query.filter_by(nickname=nickname).first() if user is None: flash('??????') return redirect(url_for('user.index')) if current_user.is_following(user): flash('??????????') return redirect(url_for('user.users', nickname=nickname)) current_user.follow(user) flash('???? %s?' % nickname) return redirect(url_for('user.users', nickname=nickname)) # ????
def unfollow(nickname): user = User.query.filter_by(nickname=nickname).first() if user is None: flash('??????') return redirect(url_for('user.index')) if not current_user.is_following(user): flash('?????????????') return redirect(url_for('user.users', nickname=nickname)) current_user.unfollow(user) flash('?????? %s ?' % nickname) return redirect(url_for('user.users', nickname=nickname))
def follow(username): user = User.query.filter_by(username=username).first() if user is None: flash('Invalid user.') return redirect(url_for('.index')) if current_user.is_following(user): flash('You are already following this user.') return redirect(url_for('.user', username=username)) current_user.follow(user) db.session.commit() flash('You are now following %s.' % username) return redirect(url_for('.user', username=username))
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.unfollow(user) db.session.commit() flash('You are not following %s anymore.' % username) return redirect(url_for('.user', username=username))
def follow(username): user= User.query.filter_by(username=username).first() if user is None: flash('Invalid user.') return redirect(url_for('.index')) if current_user.is_following(user): flash('You are already following this user.') return redirect(url_for('.user', username=username)) current_user.follow(user) flash('You are now following %s.' % username) return redirect(url_for('.user', username=username))
def follow(username): user=User.query.filter_by(username=username).first() if user is None: flash('Invalid user.') return redirect(url_for('.index')) if current_user.is_following(user): flash('You are already following this user.') return redirect(url_for('.user', username=username)) current_user.follow(user) flash('You are now following %s.' % username) return redirect(url_for('.user', username=username))
def follow_or_unfollow(username): """ follow_or_unfollow user the request will sent with ajax example returned json: status: either "good" or "error" follow: if user follow the user follow = True else follow = None msg: if there is alert msg="some alert" else msg=None category: category of the msg (warning, primary, success) """ msg = None category = None follow = False user = User.query.filter_by(name=username).first_or_404() if not current_user.is_authenticated: status = "error" msg = "Please Login or signup first" category = "warning" elif not current_user.confirmed: status = "error" msg = "Please confirm your email first" category = "warning" else: status = "good" if not current_user.is_following(user): follow = True current_user.follow(user) elif current_user.is_following(user): current_user.unfollow(user) db.session.add(current_user) db.session.commit() return jsonify({"status": status, "msg": msg, "category": category, "follow": follow })
def unfollow(username): """????""" user = User.query.filter_by(username=username).first() if user is None: return jsonify(error=constant.INVALID_USER) if not current_user.is_following(user): return jsonify(error=constant.NO_CON) try: current_user.unfollow(user) except Exception as e: return jsonify(constant.FAIL) return jsonify(error="")
def follow(username): user = User.query.filter_by(username=username).first() if user is None: flash('Invalid user.') return redirect(url_for('.index')) if current_user.is_following(user): flash('You are already following this user.') return redirect(url_for('.user', username=username)) current_user.follow(user) flash('You are now following {}'.format(username)) return redirect(url_for('.user', username=username))
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 already following this user.') return redirect(url_for('.user', username=username)) current_user.follow(user) flash('You are not following {} anymore.'.format(username)) return redirect(url_for('.user', username=username))
def follow(username): user = User.query.filter_by(username=username).first() if user is None: flash('Invalid user.') return redirect(url_for('.index')) if current_user.is_following(user): flash('You are already following this user.') return redirect('.user', username=username) current_user.follow(user) flash('You are now following %s.' %username) return redirect(url_for('.user', username=username))
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('.user', username=username) current_user.unfollow(user) flash('You are not following %s anymore.' %username) return redirect(url_for('.user', username=username))
def follow(username): user = User.query.filter_by(username=username).first() if user is None: flash(u'????') return redirect(url_for('.index')) if current_user.is_following(user): flash(u'?????????') return redirect(url_for('.user', username=username)) current_user.follow(user) flash(u'???? %s.' % username) return redirect(url_for('.user', username=username))
def unfollow(username): user = User.query.filter_by(username=username).first() if user is None: flash(u'????') return redirect(url_for('.index')) if not current_user.is_following(user): flash(u'????????') return redirect(url_for('.user', username=username)) current_user.unfollow(user) flash(u'?????? %s' % username) return redirect(url_for('.user', username=username))
def follow(username): user = User.query.filter_by(username=username).first() if user is None: flash('Invalid user') return redirect(url_for('.index')) if current_user.is_following(user): flash('You are already following this user') return redirect(url_for('.user',username=username)) current_user.follow(user) flash('You are now following %s' %username ) return redirect(url_for('.user',username=username)) #??????
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.unfollow(user) flash('You are not following %s anymore' %username) return redirect(url_for('.user',username=username)) #?????