Ejemplo n.º 1
0
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)
    )
Ejemplo n.º 2
0
Archivo: views.py Proyecto: 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))
Ejemplo n.º 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))
Ejemplo n.º 4
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))
Ejemplo n.º 5
0
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))
Ejemplo n.º 6
0
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))
Ejemplo n.º 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"})
Ejemplo n.º 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))
Ejemplo n.º 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))
Ejemplo n.º 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))
Ejemplo n.º 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))
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'})
Ejemplo n.º 13
0
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))
Ejemplo n.º 14
0
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))
Ejemplo n.º 15
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))
Ejemplo n.º 16
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('main.profile', username=username))
    current_user.follow(user)
    flash('你刚刚关注了 %s' % username)
    return redirect(url_for('main.profile', username=username))
Ejemplo n.º 17
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))
Ejemplo n.º 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))
Ejemplo n.º 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))
Ejemplo n.º 20
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('成功关注')
    return redirect(url_for('.user', username=user.username))
Ejemplo n.º 21
0
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))
Ejemplo n.º 22
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))
Ejemplo n.º 23
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))
Ejemplo n.º 24
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 %s.' % username)
    return redirect(url_for('.user', username=username))
Ejemplo n.º 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))
Ejemplo n.º 26
0
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))
Ejemplo n.º 27
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('您现在已关注此用户.')
    return redirect(url_for('.user', username=username))
Ejemplo n.º 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))
Ejemplo n.º 29
0
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})
Ejemplo n.º 30
0
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))
Ejemplo n.º 31
0
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))
Ejemplo n.º 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))
Ejemplo n.º 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))
Ejemplo n.º 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))
Ejemplo n.º 35
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' % user.username)
    return redirect(url_for('.user', username=username))
Ejemplo n.º 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))
Ejemplo n.º 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))
Ejemplo n.º 38
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 %s.' % username)
    return redirect(url_for('.user', username=username))
Ejemplo n.º 39
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("您已经关注Ta啦~")
        return redirect(url_for(".user", username=username))
    current_user.follow(user)
    flash("您正在关注 %s." % username)
    return redirect(url_for(".user", username=username))
Ejemplo n.º 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))
Ejemplo n.º 41
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('.user', username = username))
    current_user.follow(user)
    flash(u'你现在关注了%s。' % username )
    return redirect(url_for('.user', username=username))
Ejemplo n.º 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))
Ejemplo n.º 43
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))
Ejemplo n.º 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))
Ejemplo n.º 45
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))
Ejemplo n.º 46
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))
Ejemplo n.º 47
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 %s." % username)
    return redirect(url_for(".user", username=username))
Ejemplo n.º 48
0
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))
Ejemplo n.º 49
0
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))
Ejemplo n.º 50
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)  #调用User模型中定义的辅助方法follow()来联接两个用户.
    flash(u'已关注 %s.' % username)
    return redirect(url_for('.user', username=username))
Ejemplo n.º 51
0
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')
Ejemplo n.º 52
0
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))
Ejemplo n.º 53
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) #调用User模型中定义的辅助方法follow()来联接两个用户.
    flash(u'已关注 %s.' % username)
    return redirect(url_for('.user', username=username))
Ejemplo n.º 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)
Ejemplo n.º 55
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('main.user', username = username))

    current_user.follow(user)
    flash('你关注了 %s.' % username)
    return redirect(url_for('main.user', username=username))
Ejemplo n.º 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')
Ejemplo n.º 57
0
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))
Ejemplo n.º 58
0
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)