def unfollow(id): user = User.query.filter_by(id = id).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 = user.username)) if current_user.is_following(user): current_user.unfollow(user) flash(u'取消关注成功') return redirect(url_for('.user', username = user.username))
def follow(id): user = User.query.get_or_404(id) bol = False if user is None: return redirect(url_for('.index')) if current_user.is_following(user): current_user.unfollow(user) bol = False elif not current_user.is_following(user): current_user.follow(user) bol = True count = user.followers.count() - 1 return jsonify(bol=bol, count=count)
def unfollow_user(user_id): user = User.get_by_id(user_id) current_user.unfollow(user) flash(_("You are now not following") + " %s" % user.name, "success") return render_template( "user/profile.html", user=user, current_user=current_user, followed=current_user.is_following(user) )
def removefirend(user_id): if user_id is None: return abort(404) user = User.query.filter_by(id=user_id).first() if user is None: #user dose not exist return '2' if user == current_user: #can not remove one self return '3' #check friendship isfollowing = current_user.is_following(user) if isfollowing: #already added as friend #this is a one-side operation db.session.add(current_user.unfollow(user)) db.session.commit() else: #send friend request return '4' return render_template("ajax_buttons.html", btn='addfriendrequetbtn', userid=user_id)
def unfillow(username): user = User.query.filter_by(username=username).first() if user is None: return jsonify({'error': 'Invalid user'}) if not current_user.is_following(user): return jsonify({'error': 'You are not following that user'}) current_user.unfollow(user) return jsonify({'message': 'Success'})
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))
def unfollow(id): user = User.query.get_or_404(id) if (not current_user.is_following(user)): flash("You are already unfollowing this user.") return redirect(url_for("main.profile", id=user.id)) current_user.unfollow(user) flash("You are no long following %s now." % user.nickname) return redirect(url_for("main.profile", id=user.id))
def unfollow(username): user = User.query.filter_by(username=username).first_or_404() if not current_user.is_following(user): flash(u'你未关注该用户') return redirect(url_for('.user', username=username)) current_user.unfollow(user) flash(u'已取消关注') return redirect(url_for('.user', username=username))
def unfollow(username): user = User.query.filter_by(username=username).first() if user is None: return redirect(url_for('main.home')) if not current_user.is_following(user): return redirect(url_for('main.viewperson', username=username)) current_user.unfollow(user) return redirect(url_for('main.viewperson', username=username))
def unfollow(username): user = User.query.filter_by(username=username).first() if user is None: flash('该用户不存在') if not current_user.is_following(user): flash('您未关注此用户') current_user.unfollow(user) flash('您现在已取消关注该用户 %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(u'用户不存在') return redirect(url_for('main.index')) if current_user.is_following(user): flash(u'你已关注了该用户') return redirect(url_for('main.user', username=username)) current_user.follow(user) return redirect(url_for('main.user', username=username))
def unfollow(username): user = User.query.filter_by(username=username).first() if user is None: flash('用户不存在.') return redirect(url_for('main.index')) if not current_user.is_following(user): flash('您已不再关注%s.' % username) return redirect(url_for('main.user', username=username)) current_user.unfollow(user) return redirect(url_for('main.user', username=username))
def follow(username): user = User.query.filter_by(username=username).first() if user is None: return jsonify({'error': 'Invalid user'}) if user == current_user: return jsonify({'error': 'You cannot follow yourself'}) if current_user.is_following(user): return jsonify({'error': 'Already following'}) current_user.follow(user) return jsonify({'message': 'Success'})
def unfollow(username): user = User.query.filter_by(username=username).first() if user is None: flash('Invalid User') return redirect('.user', username=username) if not current_user.is_following(user): flash('You are not following the user!') current_user.unfollow(user) flash('You are not following the %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: return redirect(url_for('main.home')) if current_user.is_following(user): print ("following if current_user.is_following(user): ") return redirect(url_for('main.followers', username=username)) current_user.follow(user) print ("following") return redirect(url_for('main.viewperson', username=username))
def follow(username): user = User.query.filter_by(userName=username).first() if user is None: flash(u'没有该用户,关注失败') if current_user.is_following(user): flash(u'你已经关注过该用户,无需再次关注') return redirect(url_for('trade.trade_list')) current_user.follow(user) flash(u'成功关注%s' % username) return redirect(url_for('main.user_zone', username=username))
def follow(name): user = User.query.filter_by(name=name).first() if user is None: flash('无效用户') return redirect(url_for('.index')) if current_user.is_following(user): flash('你已经关注了这个用户') return redirect(url_for('.user', name=name)) current_user.follow(user) flash('成功关注 %s.' % name) return redirect(url_for('.user', name=name))
def unfollow(username): user = User.query.filter_by(username=username).first() if user is None: flash('Invalid User.') return redirect(url_for('main.index')) if not current_user.is_following(user): flash('You didn\'t follow this user.') return redirect(url_for('main.user_profile', username=username)) current_user.unfollow(user) flash('You have unfollowed %s.' % username) return redirect(url_for('main.user_profile', username=username))
def follow(username): user = User.query.filter_by(username=username).first() if user is None: flash('该用户不存在') return redirect(url_for('.index')) if current_user.is_following(user): flash('您已经关注此用户') return redirect(url_for('.user', username=username)) current_user.follow(user) flash('您现在已关注此用户.') return redirect(url_for('.user', username=username))
def profile(user_id): user = User.get_by_id(user_id) message = Message() msgs = message.get_message_from_user(user) return render_template( "user/profile.html", user=user, messages=msgs, current_user=current_user, followed=current_user.is_following(user), )
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('用户不存在') return redirect(url_for('.index')) if current_user.is_following(user): flash('你已关注此用户') return redirect(url_for('.user', username=username)) current_user.follow(user) flash('你关注了%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('无效用户') return redirect(url_for('.index')) if not current_user.is_following(user): flash('你已经取消关注了这位用户') return redirect(url_for('.user', username=username)) current_user.unfollow(user) flash('你现在已经取消关注了 %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(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('无效的用户名') return redirect(url_for('.index')) if current_user.is_following(user): flash('你已关注此用户,不要反复操作') return redirect(url_for('.user', username=username)) current_user.follow(user) flash('成功关注') return redirect(url_for('.user', username=user.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(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('关注失败!') return redirect(url_for('main.index')) if current_user.is_following(user): flash('已经关注该用户!') return redirect(url_for('.user', username=username)) current_user.follow(user) flash('已关注用户 %s.' % username) return redirect(url_for('main.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(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(u'非法用户') return redirect(url_for('main.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('Invalid user.') return redirect(url_for('site.index')) if not current_user.is_following(user): flash("You are already don't following this user.") return redirect(url_for('profile.view_profile', username=username)) current_user.unfollow(user) flash('You are now unfollow %s.' % username) return redirect(url_for('profile.view_profile', username=username))
def unfollow(username): user = User.query.filter_by(username = username).first() if user is None: flash(u'非法用户') return redirect(url_for('main.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 unfollow(username): user = User.query.filter_by(username=username).first() if user is None: flash("非法用户") return redirect(url_for(".index")) if not current_user.is_following(user): flash("您还没关注Ta") return redirect(url_for(".user", username=username)) current_user.unfollow(user) flash("您咩有关注 %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('无效用户.') return redirect(url_for('.index')) if current_user.is_following(user): flash('你已经关注了这个用户.') return redirect(url_for('.user',username=username)) current_user.follow(user) flash('你关注了%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("非法用户") return redirect(url_for(".index")) if current_user.is_following(user): flash("您已经关注Ta啦~") return redirect(url_for(".user", username=username)) current_user.follow(user) flash("您正在关注 %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(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): to_follow = User.query.filter_by(username=username).first() if to_follow is None: flash('Invalid user.') return redirect(url_for('.index')) if current_user.is_following(to_follow): flash('You are already following %s.' % username) return redirect(url_for('.user', username=username)) current_user.follow(to_follow) flash("Your're now following %s." % username) return redirect(url_for('.user', username=to_follow.username))
def unfollow(username): user = User.query.filter_by(username=username).first() if user is None: flash('用户不存在') return redirect(url_for('.index')) if current_user.is_following(user): current_user.unfollow(user) flash('你已取消关注%s.' % username) else: flash('你还未关注此用户') return redirect(url_for('.user', username=username)) return redirect(url_for('.user', username=username))
def unfollow(username): u = User.query.filter_by(username=username).first() if u is None: flash('Invalid user.') return redirect(url_for('.index')) if not current_user.is_following(u): flash('You have not following this user.') return redirect(url_for('.user', username=username)) current_user.unfollow(u) db.session.add(current_user) flash('You are now unfollowing %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('没有此用户') return redirect(url_for('main.index')) if not current_user.is_following(user): flash('你没有关注此用户') return redirect(url_for('main.user', username = username)) current_user.unfollow(user) flash('你不再关注 %s 了' % username) return redirect(url_for('main.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) #调用User模型中定义的辅助方法follow()来联接两个用户. 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('Invalid User.') return redirect(url_for('.index')) if current_user.is_following(user): current_user.unfollow(user) flash('You have unfollowed this user.') return (url_for('.user', username=username)) else: flash('you are not following this user.') return redirect(url_for('.user', username=username))
def check_follow(id, id2): current_user = User.query.filter(User.id == id2).first() user = User.query.filter(User.id == id).first() if user is not None: follow_status = current_user.is_following(user) return jsonify({ "status": 1, "msg": "check success", "result": follow_status }) return jsonify({"status": 0, "msg": "check fail, can't find user"})
def follow(username): '''关注用户视图函数''' user = User.query.filter_by(username = username).first() if user is None: flash('没有此用户') return redirect(url_for('main.index')) if current_user.is_following(user): flash('你已经关注此用户了') return redirect(url_for('main.user', username = username)) current_user.follow(user) flash('你关注了 %s.' % username) return redirect(url_for('main.user', username=username))
def unfollow(name): user = User.query.filter_by(name=name).first() if user is None: flash('无效用户') return redirect(url_for('.index')) if user == current_user: flash('小伙子可以的,不过用户不能取消关注自己') return redirect(url_for('.index')) if not current_user.is_following(user): flash('你没有关注该用户') return redirect(url_for('.user', name=name)) current_user.unfollow(user) flash('你已经取消关注 %s' % name) return redirect(url_for('.user', name=name))
def follow(username): if current_user.username == username: flash(messages.follow_youself_err) return redirect(url_for('user.profile', username=username)) user = User.query.filter_by(username=username).first() if user is None: flash(messages.user_not_found) return redirect('main.index') if current_user.is_following(user): flash(messages.follow_again_err) return redirect(url_for('user.profile', username=username)) # 过滤完成,允许关注 current_user.follow(user) flash(messages.follow_ok) return redirect(url_for('user.profile', username=username))
def unfollow(): request_info = json.loads(request.data) user = User.query.filter_by(id=request_info.get('id')).first() if user is None: json_str = { 'status': 'fail', 'status_code': 1, 'message': 'Invalid user' } return jsonify(json_str) if not current_user.is_following(user): json_str = { 'status': 'fail', 'status_code': 1, 'message': 'You haven`t followed this user.' } return jsonify(json_str) current_user.unfollow(user) json_str = { 'status': 'success', 'status_code': 0, 'message': 'You don`t following %s any longer.' % user.username } return jsonify(json_str)
def follow(): request_info = json.loads(request.data) user = User.query.filter_by(id=request_info.get('id')).first() if user is None: json_str = { 'status': 'fail', 'status_code': 1, 'message': 'Invalid user' } return jsonify(json_str) if current_user.is_following(user): json_str = { 'status': 'fail', 'status_code': 1, 'message': 'You are already following this user.' } return jsonify(json_str) current_user.follow(user) json_str = { 'status': 'success', 'status_code': 0, 'message': 'You are now following %s.' % user.username } return jsonify(json_str)
def unfollow(username): target_user = User.query.filter_by(username=username).first() if target_user is not None and current_user.is_following( target_user) is True: current_user.unfollow(target_user) return redirect(url_for('.user', name=username))
def profile(_id): user = User.get_by_id(_id) return render_template('user/profile.html', user=user, current_user=current_user, followed=current_user.is_following(user))
def profile(user_id): user = User.get_by_id(user_id) message = Message() msgs = message.get_message_from_user(user) return render_template('user/profile.html', user=user,messages= msgs,current_user=current_user,followed = current_user.is_following(user))
def unfollow_user(user_id): user = User.get_by_id(user_id) current_user.unfollow(user) flash(_("You are now not following")+" %s"%user.name,'success') return render_template('user/profile.html', user=user,current_user=current_user,followed = current_user.is_following(user))