コード例 #1
0
ファイル: views.py プロジェクト: danieltimpone/lurcat-flask
def follow_user(user_id):
    user = User.get_by_id(user_id)
    current_user.follow(user)
    flash(_("You are now following") + " %s" % user.name, "success")
    return render_template(
        "user/profile.html", user=user, current_user=current_user, followed=current_user.is_following(user)
    )
コード例 #2
0
ファイル: views.py プロジェクト: v2up/queyue
def follow():
    userid = request.args.get('userid')
    if userid:
        user = User.query.get(userid)
        if user:
            current_user.follow(user)
    return redirect(url_for('member.member_page', userid=userid))
コード例 #3
0
def follow(username):
    user = User.objects(username=username).first_or_404()
    if current_user.is_following(user):
        flash(u'你正在关注该用户')
        return redirect(url_for('.user', username=username))
    current_user.follow(user)
    flash(u'已成功关注')
    return redirect(url_for('.user', username=username))
コード例 #4
0
ファイル: views.py プロジェクト: LianYun/xing
def follow(id):
    user = User.query.get_or_404(id)
    if (current_user.is_following(user)):
        flash("You are already following this user.")
        return redirect(url_for("main.profile", id=user.id))
    current_user.follow(user)
    flash("You are now following %s." % user.nickname)
    return redirect(url_for("main.profile", id=user.id))
コード例 #5
0
ファイル: views.py プロジェクト: TaRyu/Pandathon
def follow(username):
    user = User.query.filter_by(username=username).first_or_404()
    if current_user.is_following(user):
        flash(u'你正在关注该用户')
        return redirect(url_for('.user', username=username))
    current_user.follow(user)
    flash(u'已成功关注')
    return redirect(url_for('.user', username=username))
コード例 #6
0
ファイル: views.py プロジェクト: danieltimpone/lurcat-flask
def follow_user(user_id):
    user = User.get_by_id(user_id)
    current_user.follow(user)
    flash(_("You are now following") + " %s" % user.name, 'success')
    return render_template('user/profile.html',
                           user=user,
                           current_user=current_user,
                           followed=current_user.is_following(user))
コード例 #7
0
def follow_user(id, id2):
    current_user = User.query.filter(User.id == id2).first()
    user = User.query.filter(User.id == id).first()
    if user is not None:
        current_user.follow(user)
        return jsonify({"status": 1, "msg": "follow success"})

    return jsonify({"status": 0, "msg": "follow fail, can't find user"})
コード例 #8
0
def follow(id):
    user = User.query.get_or_404(id)
    if (current_user.is_following(user)):
        flash("You are already following this user.")
        return redirect(url_for("main.profile", id=user.id))
    current_user.follow(user)
    flash("You are now following %s." % user.nickname)
    return redirect(url_for("main.profile", id=user.id))
コード例 #9
0
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('.index', username=username))
    current_user.follow(user)
    return redirect(url_for('.index',username=username))
コード例 #10
0
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('您已关注了%s.' % username)
        return redirect(url_for('main.user', username=username))
    current_user.follow(user)
    return redirect(url_for('main.user', username=username))
コード例 #11
0
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('您已关注了%s.' % username)
		return redirect(url_for('main.user', username=username))
	current_user.follow(user)
	return redirect(url_for('main.user', username=username))
コード例 #12
0
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'})
コード例 #13
0
ファイル: views.py プロジェクト: eddwinn/bitCoin
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))
コード例 #14
0
ファイル: views.py プロジェクト: Can2studio/jxnugo
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))
コード例 #15
0
ファイル: views.py プロジェクト: Abirdcfly/flask-blog
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_page', username=username))
    current_user.follow(user)
    flash(u'你关注了 %s.' % username)
    return redirect(url_for('main.user_page', username=username))
コード例 #16
0
ファイル: views.py プロジェクト: chinaJack/flaskblog
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.profile', username=username))
    current_user.follow(user)
    flash('你刚刚关注了 %s' % username)
    return redirect(url_for('main.profile', username=username))
コード例 #17
0
ファイル: views.py プロジェクト: StoneHo/blog
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))
コード例 #18
0
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('.profile', id=user.id))
    current_user.follow(user)
    flash(u'你已经关注了该用户')
    return redirect(url_for('.profile', id=user.id))
コード例 #19
0
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))
コード例 #20
0
ファイル: views.py プロジェクト: WangShengguang/Mysite
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))
コード例 #21
0
ファイル: views.py プロジェクト: razorboy73/flask-blog
def follow(username):
    user = User.query.filter_by(username=username).first()
    if user is None:
        flash("No such loser user")
        return redirect(url_for(".index"))
    if current_user.is_following(user):
        flash("Hey, you are already following them")
        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))
コード例 #22
0
ファイル: views.py プロジェクト: xinqiu/Flask-Web
def follow(username):
    user = User.query.filter_by(username=username).first()
    if user is None:
        flash('该用户不存在.'.decode('utf-8'))
        return redirect(url_for('.index'))
    if current_user.is_following(user):
        flash('你已经关注该用户.'.decode('utf-8'))
        return redirect(url_for('.user', username=username))
    current_user.follow(user)
    flash('你开始关注 %s.'.decode('utf-8') % username)
    return redirect(url_for('.user', username=username))
コード例 #23
0
ファイル: views.py プロジェクト: yelongyu/chihu
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))
コード例 #24
0
ファイル: views.py プロジェクト: ShawnPengxy/Flask-madeBlog
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))
コード例 #25
0
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_page', username=username))
    current_user.follow(user)
    flash(u'你关注了 %s.' % username)
    return redirect(url_for('main.user_page', username=username))
コード例 #26
0
ファイル: views.py プロジェクト: zacniewski/monkey-book
def follow(monkeyname):
    monkey = Monkey.query.filter_by(monkeyname=monkeyname).first()
    if monkey is None:
        flash('Invalid monkey.')
        return redirect(url_for('.view_profiles'))
    if current_user.is_following(monkey):
        flash('You are already following this monkey.')
        return redirect(url_for('.monkey', monkeyname=monkeyname))
    current_user.follow(monkey)
    flash('You are now following %s.' % monkeyname)
    return redirect(url_for('.monkey', monkeyname=monkeyname))
コード例 #27
0
ファイル: views.py プロジェクト: RachelQ1103/QiuBai
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))
コード例 #28
0
def follow(storename):
	store = Store.query.filter_by(name=storename).first()
	if store is None:
		flash('Invalid user.')
		return redirect(url_for('.index'))
	if current_user.is_following(store):
		flash('You are already following this host.')
		return redirect(url_for('.store', id=store.id))
	current_user.follow(store)
	flash('You are now following % s.' % storename)
	return redirect(url_for('.store', id=store.id))
コード例 #29
0
ファイル: views.py プロジェクト: theLastTrain/seaside
def follow(username):
    user = User.query.filter_by(username=username).first()
    if user is None:
        flash('用户不存在', category='danger')
        return redirect(url_for('.index'))
    if current_user.is_following(user):
        current_user.unfollow(user)
        return jsonify({'following': False})
    else:
        current_user.follow(user)
        return jsonify({'following': True})
コード例 #30
0
ファイル: views.py プロジェクト: QLGu/flask-zhihu-demo
def follow(id):
    user = User.query.filter_by(id=id).first()
    if user is None:
        flash('Invalid user.')
        return redirect(url_for('main.index'))
    if current_user.is_following(user):
        flash('你已经关注了该用户。')
        return redirect(url_for('main.user', id=id))
    current_user.follow(user)
    flash('你关注了 %s。' % user.name)
    return redirect(url_for('main.user', id=id))
コード例 #31
0
ファイル: views.py プロジェクト: harryxxx/myblog
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))
コード例 #32
0
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))
コード例 #33
0
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 {0}.".format(username))
    return redirect(url_for(".user", username=username))
コード例 #34
0
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))
コード例 #35
0
ファイル: views.py プロジェクト: mvbn6789/flask-blog
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' % user.username)
    return redirect(url_for('.user', username=username))
コード例 #36
0
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('.profile', username=username))
    current_user.follow(user)
    flash('关注成功')
    return redirect(url_for('.profile', username=username))
コード例 #37
0
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('.profile', id=user.id))
    current_user.follow(user)
    flash(u'你已经关注了该用户')
    return redirect(url_for('.profile', id=user.id))
コード例 #38
0
ファイル: views.py プロジェクト: sjl421/06-PythonApply
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))
コード例 #39
0
ファイル: views.py プロジェクト: guo-ge/hellowor1d
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))
コード例 #40
0
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))
コード例 #41
0
ファイル: views.py プロジェクト: zhangming0411/shuizhudan
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))
コード例 #42
0
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))
コード例 #43
0
ファイル: views.py プロジェクト: dreammis/Flask_P
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))
コード例 #44
0
def follow(username):
    user = User.query.filter_by(username=username).first()
    if user is None:
        flash('该用户不存在.'.decode('utf-8'))
        return redirect(url_for('.index'))
    if current_user.is_following(user):
        flash('你已经关注该用户.'.decode('utf-8'))
        return redirect(url_for('.user', username=username))
    current_user.follow(user)
    flash('你开始关注 %s.'.decode('utf-8') % username)
    return redirect(url_for('.user', username=username))
コード例 #45
0
ファイル: views.py プロジェクト: liulixiang1988/FlaskStudy
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))
コード例 #46
0
ファイル: views.py プロジェクト: eltonto187/flaskr
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))
コード例 #47
0
ファイル: views.py プロジェクト: mandoku/mdweb
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))
コード例 #48
0
ファイル: views.py プロジェクト: TonyGu423/flask-scrapy
def follow(username):
    user = User.query.filter_by(username = username).first()
    if user is None:
        abort(404)
        '''
    f = Follow(followers = current_user, followed = user)
    db.session.add(f)
    db.session.commit()
    '''
    current_user.follow(user)
    flash('已成功关注')
    return redirect(url_for('main.user', username = username))
コード例 #49
0
ファイル: views.py プロジェクト: peter14f/flasky
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))
コード例 #50
0
ファイル: views.py プロジェクト: yaoice/flask
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))
コード例 #51
0
ファイル: views.py プロジェクト: mvbn6789/flask-blog
def follow_ajax(username):
    user = User.query.filter_by(username=username).first()
    if user is None:
        print jsonify(result='user_is_none')
        return jsonify(result='user_is_none')
    if current_user.is_following(user):
        current_user.unfollow(user)
        print jsonify(result='user_unfollowed')
        return jsonify(result='user_unfollowed')
    current_user.follow(user)
    print jsonify(result='user_followed')
    return jsonify(result='user_followed')
コード例 #52
0
ファイル: views.py プロジェクト: peter14f/flasky
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))
コード例 #53
0
ファイル: views.py プロジェクト: yaoice/flask
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))
コード例 #54
0
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)
コード例 #55
0
ファイル: views.py プロジェクト: Dew789/Game-Community
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))
コード例 #56
0
def follow_user():
    user_id = request.values.get('user_id')
    user = User.query.get(user_id)
    if user:
        if user == current_user:
            return jsonify(ok=False, message='Cannot follow yourself')
        elif user in current_user.users_following:
            return jsonify(
                ok=False,
                message='You have already followed the specified user')
        current_user.follow(user)
        user.notify('follow', user)
        return jsonify(ok=True)
    else:
        return jsonify(ok=False, message='User does not exist')
コード例 #57
0
ファイル: views.py プロジェクト: gansu620/GalaIO-GalaCoding
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))
コード例 #58
0
ファイル: account.py プロジェクト: isuker/snippets
def follow(user_id):
    user = User.query.get_or_404(user_id)

    if user == current_user:
        flash(u"你不能关注自己", "error")
        return jsonify(success=True, 
                       reload=True)

    current_user.follow(user)
    current_user.save()
    user.save()
    save_action('"' + current_user.username + '"' + u"关注 了 "+ '"' + user.username + '"')
    save_action(u"%s 关注了 %s" %(current_user.username, user.username)  ) 

#    body = render_template("emails/followed.html",
#                           user=user)
#    mail.send_message(subject=u"%s 关注了你" % current_user.username,
#                      body=body,
#                      sender=ADMIN_MAIL,
#                      recipients=[user.email])
    return jsonify(success=True,
                   reload=True)