예제 #1
0
파일: views.py 프로젝트: Git-Hexin/zhihuweb
def unfollow(id):
    '取消关注用户'
    user = User.query.get_or_404(id)
    if user != current_user and current_user.is_following(user):
        current_user.unfollow(user)
    fans_num = user.fans.count()
    return jsonify({"fans_num" : fans_num})
예제 #2
0
파일: views.py 프로젝트: angcbi/flaskr
def follow(userid):
    user = User.query.get_or_404(userid)
    if current_user.is_following(user):
        flash(u'您已关注过%s, 无需再次关注' % user.username)
        return redirect(url_for('main.user', userid=user.id))
    current_user.follow(user)
    flash(u'您现在已关注%s' % user.username)
    return redirect(url_for('main.user', userid=user.id))
예제 #3
0
파일: views.py 프로젝트: angcbi/flaskr
def unfollow(userid):
    user = User.query.get_or_404(userid)
    if not current_user.is_following(user):
        flash(u'您未关注%s, 无需取消关注' % user.username)
        return redirect(url_for('main.user', userid=user.id))
    current_user.unfollow(user)
    flash(u'您现在已经取消关注%s' % user.username)
    return redirect(url_for('main.user', userid=user.id))
예제 #4
0
파일: views.py 프로젝트: Enigmastun/book
def follow(username):
    user = User.query.filter_by(username=username).first()
    if user is None:
        flash('Invalid User')
        return redirect(url_for('main.index'))
    if current_user.is_following(user):
        flash('You have already following this user')
        return redirect('auth.user', username=username)
    current_user.follow(user)
    return redirect(url_for('auth.user', username=username))
예제 #5
0
파일: views.py 프로젝트: wrzto/flasky
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 are not follow %s.'%user.username)
		return redirect(url_for('main.user',username=username))
	current_user.unfollow(user)
	return redirect(url_for('main.user',username=username))
예제 #6
0
파일: views.py 프로젝트: bean-jelly/blog
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')
    return redirect(url_for('.user', username=username))
예제 #7
0
파일: index.py 프로젝트: bodii/test-code
def unfollow(username):
    user = User.query.filter_by(username=username).first()
    if user is None:
        flash('Invalid user.')
        return redirect(url_for('.home'))
    if current_user.is_following(user) is None:
        flahs('You have not followed this user.')
        return redirect(url_for('.home'))
    current_user.unfollow(user)
    flash('You are now unfollowing %s.' % username)
    return redirect(url_for('.user', username=username))
예제 #8
0
파일: views.py 프로젝트: zayng/myApp
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('你还没有关注该用户.')
        return redirect(url_for('.user', username=username))
    current_user.unfollow(user)
    flash('You unfollow {username}'.format(username=username))
    return redirect(url_for('.user', username=username))
예제 #9
0
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))
예제 #10
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))
예제 #11
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))
예제 #12
0
파일: views.py 프로젝트: dogezhou/my_flask
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))
예제 #13
0
파일: views.py 프로젝트: dearestu/mineblog
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))
예제 #14
0
파일: views.py 프로젝트: wangrenlearn/flask
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.' % username)
    return redirect(url_for('.user',username=username))
예제 #15
0
파일: views.py 프로젝트: wangrenlearn/flask
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))
예제 #16
0
파일: views.py 프로젝트: dearestu/mineblog
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))
예제 #17
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))
예제 #18
0
파일: views.py 프로젝트: yibuyi/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))
예제 #19
0
파일: views.py 프로젝트: rederry/kkFlasky
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))
예제 #20
0
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))
예제 #21
0
def follow(username):
    u = User.query.filter_by(username=username).first()
    if u is None:
        flash("Invalid user")
        return redirect(url_for(".index"))
    if current_user.is_following(u):
        flash("Already following")
        return redirect(url_for(".user", username=username))
    current_user.follow(u)
    flash("You are following %s." % username)
    return redirect(url_for(".user", username=username))
예제 #22
0
파일: views.py 프로젝트: mapingfan/MyWebApp
def unfollow(username):
    user = User.query.filter_by(username=username).first()
    if user is None:
        flash('Invalid user .')
        return redirect('.index')
    if not current_user.is_following(user):
        flash('You have not followed this guy .')
        return redirect(url_for('.user', username=username))
    current_user.unfollow(user)
    flash("You have unfollowed %s " % username)
    return redirect(url_for('.user', username=username))
예제 #23
0
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("Not following already")
        return redirect(url_for(".user", username=username))
    current_user.unfollow(u)
    flash("You are now not following %s." % username)
    return redirect(url_for(".user", username=username))
예제 #24
0
def follow(id):
    user = User.query.filter_by(id=id).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'))
    current_user.follow(user)
    flash(u'关注%s成功' %user.username)
    return redirect(url_for('.user', id=id))
예제 #25
0
def follow(username):
    u = User.query.filter_by(username=username).first()
    if u is None:
        flash(u'未找到指定用户')
        return redirect(url_for('.index'))
    if current_user.is_following(u):
        flash(u'你已经关注他了')
        return redirect('.user', username=username)
    current_user.follow(u)
    flash(u'关注了{0}'.format(username))
    return redirect(url_for('.user', username=username))
예제 #26
0
파일: views.py 프로젝트: Infixz/chengs.site
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))
예제 #27
0
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))
예제 #28
0
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', id=id))
    current_user.unfollow(user)
    flash(u'取消关注成功%s' % user.username)
    return redirect(url_for('.user', id=id))
예제 #29
0
파일: views.py 프로젝트: xjlzyi/Python
def unfollow(username):
    user = User.query.filter_by(username=username).first()
    if user is None:
        flash('Invalil 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))
예제 #30
0
파일: views.py 프로젝트: er3456qi/FlaskBlog
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 have not followed this user')
        return redirect(url_for('.user', username=username))
    current_user.unfollow(user)
    flash('You are now unfollowed {}'.format(username))
    return redirect(url_for('.user', username=username))
예제 #31
0
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)
    db.session.commit()
    flash('你没有关注 %s ' % username)
    return redirect(url_for('.user', username=username))
예제 #32
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))
예제 #33
0
파일: views.py 프로젝트: wenliangsun/Flasky
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 follow 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))
예제 #34
0
def unfollow(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.unfollow(user)
    db.session.commit()
    flash(u'您已取消对%s的关注.' % username)
    return redirect(url_for('main.user', username=username))
예제 #35
0
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))
예제 #36
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)
    db.session.commit()
    flash('You are now following %s.' % username)
    return redirect(url_for('.user', username=username))
예제 #37
0
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_profile', username=username))
예제 #38
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)
    db.session.commit()
    flash('已关注 %s 。' % username)
    return redirect(url_for('.user', username=username))
예제 #39
0
def follow(username):
    user = User.query.filter_by(username=username).first()
    if user is None:
        flash('Invalid user.')
        return redirect(url_for('home.html'))
    if current_user.is_following(user):
        flash('You are already following this user.')
        return redirect(url_for('user_posts.html', username=username))
    current_user.follow(user)
    db.session.commit()
    flash('You are now following %s.' % username, 'succes')
    return redirect(url_for('main.home'))
예제 #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', usernmae=username))
    current_user.follow(user)
    flash('成功关注  %s.' % username)
    return redirect(url_for('.user', username=username))
예제 #41
0
파일: views.py 프로젝트: imfog/iflasky
def unfollow(username):
    user = User.query.filter_by(username=username).first()
    if user is None:
        flash('The user is not existed.', 'danger')
        return redirect(url_for('main.index'))
    elif not current_user.is_following(user):
        flash('You have not followed %s.' % username, 'info')
        return redirect(url_for('main.user_profile', username=username))
    else:
        current_user.unfollow(user)
        flash('You have unfollowed %s successfully.' % username, 'success')
        return redirect(url_for('main.user_profile', username=username))
예제 #42
0
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)
    return jsonify(message='User followed.')
예제 #43
0
def unfollow(username):
    # 取消关注
    user = User.query.filter_by(username=username).first()
    if user is None or current_user == user:
        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('你取消关注了{}!'.format(username))
    return redirect(url_for('.user', username=username))
예제 #44
0
def follow(id):
    user = User.query.get(id)
    if user is None:
        return jsonify(message='Not found.')
    if user == current_user:
        return jsonify(message='Cannot follow self')
    if current_user.is_following(user):
        return jsonify(message='Already following')

    current_user.follow(user)
    db.session.commit()
    return jsonify(message='Following')
예제 #45
0
def follow(username):
    user = User.query.filter_by(username=username).first()
    if user is None:
        flash('无效的用户')
        return redirect(url_for('post.index'))
    if current_user.is_following(user):
        flash('您已经关注此用户')
        return redirect(url_for('.username_router', username=username))
    current_user.follow(user)
    db.session.commit()
    flash('您现在已经关注 %s.' % username)
    return redirect(url_for('.username_router', username=username))
예제 #46
0
def unfollow(username):
    user = User.query.filter_by(username=username).first()
    if user is None:
        flash('Invalid user.')
        return redirect(url_for('home.html'))
    if not current_user.is_following(user):
        flash('You are not following this user.')
        return redirect(url_for('user_posts.html', username=username))
    current_user.unfollow(user)
    db.session.commit()
    flash('You are not following %s anymore.' % username, 'danger')
    return redirect(url_for('main.home'))
예제 #47
0
def unfollow(name):
    '''取关用户'''
    user = User.query.filter_by(name=name).first()
    if not user:
        flash('该用户不存在。', 'warning')
        return redirect(url_for('front.index'))
    if not current_user.is_following(user):
        flash('你并未关注此用户。', 'info')
    else:
        current_user.unfollow(user)
        flash('成功取关此用户。', 'success')
    return redirect(url_for('.index', name=name))
예제 #48
0
def follow(username):
    # 关注该资料页用户
    user = User.query.filter_by(username=username).first()
    if user is None or current_user == user:
        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('你成功关注了{}。'.format(username))
    return redirect(url_for('.user', username=username))
예제 #49
0
def unfollow(username):
    user = User.query.filter_by(username=username).first()
    if user is None:
        flash('Invalid user.')
        return redirect(url_for('.index'))
    elif not current_user.is_following(user):
        flash("You don't already follow this user.")
    else:
        current_user.unfollow(user)
        db.session.commit()
        flash(f'You have unfollowed {username}.')
    return redirect(url_for('.user', username=username))
예제 #50
0
def un_follow(username):
    if not current_user.is_authenticated:
        return redirect(url_for('main.home'))
    user = User.query.filter_by(username=username).first_or_404()
    if current_user.is_following(user):
        current_user.unfollow(user)
        flash(f'You have unfollowed {user.username}', 'info')
    else:
        current_user.follow(user)
        flash(f'You have followed {user.username}', 'info')
    db.session.commit()
    return redirect(url_for('user.home', username=user.username))
예제 #51
0
파일: views.py 프로젝트: Ray57468260/flasky
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 have not followed this user yet.')
        return redirect(url_for('.user', username=username))
    current_user.unfollow(user)
    db.session.commit()
    flash('You have cancelled following.')
    return redirect(url_for('.user', username=username))
예제 #52
0
파일: views.py 프로젝트: junlish/pyweb
def unfollow(username):
    user = User.query.filter_by(username=username).first()
    if user is None:
        flash("关注的用户不存在:{}".format(username))
        return redirect(url_for(".index"))
    if current_user.is_following(user):
        current_user.unfollow(user)
        flash("取消关注{}成功".format(username))
        return redirect(url_for('.user', username=username))
    else:
        flash("您并未关注{},无法操作".format(username))
        return redirect(url_for('.user', username=username))
예제 #53
0
파일: views.py 프로젝트: zhj0513/WeBlog
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)
    db.session.commit()
    flash('您刚关注了 %s.' % username)
    return redirect(url_for('.user', username=username))
예제 #54
0
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 are not follow %s now.' % username)
        return redirect(url_for('.user', username=username))
    else:
        flash('You not follow %s' % username)
        return redirect(url_for('.user', username=username))
예제 #55
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 following this user.')
        redirect(url_for('.user', username=username))
    current_user.follow(user)
    flash('You are following %s.' % user)
    return redirect(url_for('.user', username=username))
예제 #56
0
파일: views.py 프로젝트: zhj0513/WeBlog
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)
    db.session.commit()
    flash('您取消了对用户 %s 的关注.' % username)
    return redirect(url_for('.user', username=username))
예제 #57
0
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('Your are not following this user.')
        return redirect(url_for('.user', username=username))
    current_user.un_follow(user)
    db.session.commit()
    flash('You are not following {} anymore.'.format(username))
    return redirect(url_for('.user', username=username))
예제 #58
0
def follow(username):
    user = User.query.filter_by(username=username).first()
    if user is None:
        flash(u'无效用户.')
        return redirect(url_for('mian.index'))
    if current_user.is_following(user):
        flash(u'你已经关注了他.')
        return redirect(url_for('main.user', username=username))
    current_user.follow(user)
    db.session.commit()
    flash(u'你已经将%s加入关注名单.' % username)
    return redirect(url_for('main.user', username=username))
예제 #59
0
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))
예제 #60
0
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 follower of this user.')
        return redirect(url_for('.user', username=username))
    current_user.unfollow(user)
    db.session.commit()
    flash("Unfollow user {} success.".format(user.username))
    return redirect(url_for('.user',username=username))