Exemple #1
0
def unfollow():
    userid = request.args.get('userid')
    if userid:
        user = User.query.get(userid)
        if user:
            current_user.unfollow(user)
    return redirect(url_for('member.member_page', userid=userid))
Exemple #2
0
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 follow():
    if request.method == 'GET':
        return render_template("find.html")
    elif request.method == 'POST':
        search = request.form['txtSearch']
        usr = User.query.filter_by(username=search)
        results = usr.all()
        if len(results) == 1:
            usr = usr.one()
            f = [str(u.username) for u in usr.followers.all()]
            if search in f:
                flash('Already following %s' % search)
                return redirect(url_for('index'))
            elif search == str(current_user.username):
                flash('Users cannot follow themselves')
                return redirect(url_for('index'))
            else:
                current_user.unfollow(usr)
                new_follower = current_user.follow(usr)
                db.session.add(new_follower)
                db.session.commit()
                flash('You are now following %s' % search)
                return redirect(url_for('index'))
        else:
            flash('No user found with username "%s"' % search)
            return render_template("find.html")
    else:
        abort(405)
Exemple #4
0
def unfollow(username):
    user = User.query.filter_by(userName=username).first()
    if user is None:
        flash(u'没有该用户')
    current_user.unfollow(user)
    flash(u'成功取消对%s的关注' % username)
    return redirect(url_for('main.user_zone', username=username))
Exemple #5
0
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))
Exemple #6
0
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 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'})
Exemple #8
0
def unfollow(username):
    user = User.query.filter_by(username = username).first()
    if user is None:
        flash('Invalid request!')
        return redirect(url_for('main.index'))
    current_user.unfollow(user)
    flash('Cancel follow... success!')
    return redirect(url_for('main.user', username = user.username))
Exemple #9
0
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))
Exemple #10
0
def unfollow_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.unfollow(user)
        return jsonify({"status": 1, "msg": "unfollow success"})

    return jsonify({"status": 0, "msg": "follow fail, can't find user"})
Exemple #11
0
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))
Exemple #12
0
def unfollow(username):
    user = User.objects(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))
Exemple #13
0
def unfollow(username):
    user = User.query.filter_by(username=username).first()
    if user is None:
        flash('用户不存在。')
        return redirect(url_for('.index'))    
    current_user.unfollow(user)
    flash('你不再关注 %s。' % username)
    return redirect(url_for('.user', username=username))    
Exemple #14
0
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))
Exemple #15
0
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))
Exemple #16
0
def unfollow(user_id):
    user = User.query.get_or_404(user_id)
    current_user.unfollow(user)
    current_user.save()
    user.save()

    save_action('"' + current_user.username + '"' + u"关注 了 "+ '"' + user.username + '"')
    return jsonify(success=True,
                   reload=True)
Exemple #17
0
def unfollow(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):
        current_user.unfollow(user)
        return redirect(url_for('.index', username=username))
    
    return redirect(url_for('.index',username=username))
Exemple #18
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) is False:
		flash('You are not following them')
		return redirect(url_for('.user', username=username))
	current_user.unfollow(user)
	return redirect(url_for('.user', username=username))
Exemple #19
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')
  current_user.unfollow(user)
  flash('You are not following %s anymore' % 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('您已不再关注%s.' % username)
        return redirect(url_for('main.user', username=username))
    current_user.unfollow(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))
Exemple #22
0
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))
Exemple #23
0
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))
Exemple #24
0
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('.profile', id=user.id))
    current_user.unfollow(user)
    flash(u'已经对该用户取消关注')
    return redirect(url_for('.profile', id=user.id))
Exemple #25
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))
Exemple #26
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))
Exemple #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("您还没关注Ta")
        return redirect(url_for(".user", username=username))
    current_user.unfollow(user)
    flash("您咩有关注 %s anymore." % username)
    return redirect(url_for(".user", username=username))
Exemple #28
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 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))
Exemple #29
0
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.profile', username=username))
    current_user.unfollow(user)
    flash('你已经取消关注 %s ' % username)
    return redirect(url_for('main.profile', username=username))
Exemple #30
0
def unfollow(username):
    user = User.query.filter_by(username=username).first()
    if user is None:
        flash('该用户不存在.'.decode('utf-8'))
        return redirect(url_for('.index'))
    if not current_user.is_following(user):
        flash('你没关注该用户.'.decode('utf-8'))
        return redirect(url_for('.user', username=username))
    current_user.unfollow(user)
    flash('你不在关注 %s.'.decode('utf-8') % username)
    return redirect(url_for('.user', username=username))
Exemple #31
0
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))
Exemple #32
0
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))
Exemple #33
0
def unfollow(storename):
	store = Store.query.filter_by(name=storename).first()
	if store is None:
		flash('Invalid user.')
		return redirect(url_for('.index'))
	if not current_user.is_following(store):
		flash('You are not following this user.')
		return redirect(url_for('.store', id=store.id))
	current_user.unfollow(store)
	flash('You are not following %s anymore.' % storename)
	return redirect(url_for('.store', id=store.id))
Exemple #34
0
def unfollow(username):
    to_unfollow = User.query.filter_by(username=username).first()
    if to_unfollow is None:
        flash('Invalid user.')
        return redirect(url_for('.index'))
    if not current_user.is_following(to_unfollow):
        flash('You are not following %s.' % username)
        return redirect(url_for('.user', username=username))
    current_user.unfollow(to_unfollow)
    flash("You've unfollowed %s." % username)
    return redirect(url_for(".user", username=to_unfollow.username))
Exemple #35
0
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))
Exemple #36
0
def unfollow(username):
    user = User.query.filter_by(username=username).first()
    if user is None:
        flash('Invalid User.', 'danger')
        return redirect(url_for('.index'))
    if not current_user.is_following(user):
        flash('You are not following this user.', 'warning')
        return redirect(url_for('.user', username=username))
    current_user.unfollow(user)
    flash('You are no longer following %s.' % username, 'warning')
    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('.profile', id=user.id))
    current_user.unfollow(user)
    flash (u'已经对该用户取消关注')
    return redirect(url_for('.profile', id=user.id))
Exemple #38
0
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))
Exemple #39
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):
        flash('You have unfollowed this user.')
        current_user.unfollow(user)
        return redirect(url_for('.user', username=username))
    flash('You can not unfollow this user.')
    return redirect(url_for('.user', username=username))
Exemple #40
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))
Exemple #41
0
def unfollow(username):
    user = User.query.filter_by(username=username).first()
    if user is None:
        flash("No such loser user")
        return redirect(url_for(".index"))
    if not current_user.is_following(user):
        flash("Hey, you are not following them to begin with")
        return redirect(url_for(".user", username=username))
    current_user.unfollow(user)
    flash("Hey, you have unfollowed {}".format(user))
    return redirect(url_for(".user", username=username))
Exemple #42
0
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))
Exemple #43
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.unfollow(user):
        flash('You have already following this user.')
        return redirect(url_for('.user', username=username))
    current_user.unfollow(user)
    flash('You have unfollowed %s.' % username)
    return redirect(url_for('.user', username=username))
Exemple #44
0
def unfollow(username):
	user = User.query.filter_by(username=username).first()
	if user is None:
		flash('Invalid user','danger')
		return redirect(url_for('.index'))
	if not current_user.is_following(user):
		flash('You are not following this user.')
		return redirect(usr_for('.user',username=username))
	current_user.unfollow(user)
	flash('You are not following %s now.' % username,'success')
	return redirect(url_for('.user',username=username))
Exemple #45
0
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' % user.username)
    return redirect(url_for('.user', username=username))
Exemple #46
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))
def unfollow(username):
    user = User.query.filter_by(username=username).first()
    if not user:
        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 haven\'t been followed %s yet.' % username)
    return redirect(url_for('.user', username=username))
Exemple #48
0
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))
Exemple #49
0
def unfollow(username):
    user = User.query.filter_by(username=username).first()
    if user is None:
        flash('Invalid User!')
        redirect(url_for('.index'))
    if current_user.is_following(user):
        flash('You are not this user\'s follower')
        redirect(url_for('.user', username=username))
    current_user.unfollow(user)
    flash('Now you are not this user\'s follower')
    return redirect(url_for('.user', username=username))
Exemple #50
0
def unfollow(username):
    to_unfollow = User.query.filter_by(username=username).first()
    if to_unfollow is None:
        flash('Invalid user.')
        return redirect(url_for('.index'))
    if not current_user.is_following(to_unfollow):
        flash('You are not following %s.' % username)
        return redirect(url_for('.user', username=username))
    current_user.unfollow(to_unfollow)
    flash("You've unfollowed %s." % username)
    return redirect(url_for(".user", username=to_unfollow.username))
Exemple #51
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 do not follow this user.')
        return redirect(url_for('.user', username=username))
    current_user.unfollow(user)
    flash('You have unfollowed %s' % username)
    return redirect(url_for('.user', username=username))
Exemple #52
0
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))
Exemple #53
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 not current_user.is_following(user):
        flash(u'你没有关注他!')
        return redirect(url_for('main.user_page', username=username))
    current_user.unfollow(user)
    flash(u'你不再关注 %s ' % username)
    return redirect(url_for('main.user_page', username=username))
Exemple #54
0
def unfollow(username):
    user = User.query.filter_by(username=username).first()
    if user is None:
        flash('无效的用户')
        return redirect(url_for('.index'))
    if not user.is_following(user):
        flash('你没有关注此用户')
        return redirect(url_for('.user', username=username))
    current_user.unfollow(user)
    flash('你已取消对{{user.username}}的关注')
    return redirect(url_for('.user', username=user.username))
Exemple #55
0
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))
Exemple #56
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('.profile', username=username))
    current_user.unfollow(user)
    flash('您已取消对此用户的关注')
    return redirect(url_for('.profile', username=username))
Exemple #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("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))
Exemple #58
0
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))
Exemple #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))