def unfollow(user_id): user = User.query.get(user_id) if not user: abort(404) current_user.unfollow(user) new_url = url_for('user.follow', user_id = user.id) return jsonify(data=user.id, status=200, message="关注", newurl=new_url)
def unfollow(username): u = User.query.filter_by(username=username).first() if u is None: flash(u'未找到指定用户') current_user.unfollow(u) flash(u'你已经取消关注他了') return redirect(url_for('.user', username=username))
def unfollow_user(username): user = User.query.filter_by(username=username).first() if user is not None: current_user.unfollow(user) else: abort(404) return redirect(url_for('main.user_profile', username=username))
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})
def unfollow(username): user = User.query.filter_by(username=username).first() if user is None: flash('the user is not valid') return redirect(request.referrer) current_user.unfollow(user) return redirect(url_for('main.user', username=user.username))
def unfollow(username): user = User.query.filter_by(username=username).first() if user is None: flash('Invalid user.') return redirect(url_for('.index')) current_user.unfollow(user) flash('You are now not following % s.' % username) return redirect(url_for('.user', username=username))
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))
def unfollow(username): user = User.query.filter_by(username=username).first() if user is None: flash('Invalid User') return redirect('main.index') if not current_user.is_following(user): flash('You are not following this user') return redirect(url_for('auth.user', username=username)) current_user.unfollow(user) return redirect(url_for('auth.user', username=username))
def unfollow(username): user = User.query.filter_by(username=username).first() if user is None: flash('Invalid user') return redirect(url_for('.index')) if not current_user.is_following(user): flash('You 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))
def unfollow(username): user = User.query.filter_by(username=username).first() if user is None: flash('user is not exists.') return redirect(url_for('.index')) if not user.is_followed_by(current_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' % username) return redirect(url_for('.user', username=username))
def unfollow(username): user = User.query.filter_by(username=username).first() if user is None: flash('非法用户') return redirect(url_for('.index')) if not current_user.is_following(user): flash('该用户你未关注.') return redirect(url_for('.user', username=username)) current_user.unfollow(user) flash('已成功取消关注该用户 %s.' % username) return redirect(url_for('.user', username=username))
def unfollow(username): user = User.query.filter_by(username=username).first() if user is None: flash('Invalid user.') return redirect(url_for('.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))
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))
def unfollow(username): user = User.query.filter_by(username=username).first() if user is None: flash('无效用户') return redirect(url_for('.index')) if not current_user.is_following(user): flash('你没有关注这个用户') return redirect(url_for('.user', username=username)) current_user.unfollow(user) flash('你不再关注%s了' % username) return redirect(url_for('.user', username=username))
def unfollow(username): user = User.query.filter_by(username=username).first() if user is None: flash('Invalid user') return redirect(url_for('main.index')) if not current_user.is_following(user): flash('You have not follow this user.') return redirect(url_for('main.user', username=username)) current_user.unfollow(user) flash('Unfollow user %s successfully' % username) return redirect(url_for('main.user', username=username))
def unfollow(username): user = User.query.filter_by(username=username).first() if user is None: flash("Invalid user.") return redirect(url_for(".index")) if not current_user.is_following(user): flash("You are not following this user.") return redirect(url_for(".user", username=username)) current_user.unfollow(user) flash("You are not following %s anymore." % username) return redirect(url_for(".user", username=username))
def unfollow(username): user = User.query.filter_by(username=username).first() if user is None: flash('Usuario invalido.') return redirect(url_for('.index')) if not current_user.is_following(user): flash('Tu no sigues a este usuario.') return redirect(url_for('.user', username=username)) current_user.unfollow(user) flash('Ya no sigues a %s.' % username) return redirect(url_for('.user', username=username))
def unfollow(username): user = User.query.filter_by(username=username).first() if user is None: flash('Invalid user .') return redirect('.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))
def unfollow(username): user = User.query.filter_by(username=username).first() if user is None: flash('非用户.') return redirect(url_for('.index')) if not current_user.is_following(user): flash('您没有关注该用户.') return redirect(url_for('.user', username=username)) current_user.unfollow(user) flash('您不再关注用户 %s ' % username) return redirect(url_for('.user', username=username))
def unfollow(username): user = User.query.filter_by(username=username).first() if user is None: flash(u'错误的用户.') return redirect(url_for('.index')) if not current_user.is_following(user): flash(u'你取消关注了此用户') return redirect(url_for('.user', username=username)) current_user.unfollow(user) flash(u'你不是%s的粉丝.' % username) return redirect(url_for('.user', username=username))
def 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))
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))
def unfollow(username): user = User.query.filter_by(username=username).first() if user is None: flash(u'非法用户操作') return redirect(url_for('.index')) if not current_user.is_following(user): flash(u'你已取消关注该用户') return redirect(url_for('.user', username=username)) current_user.unfollow(user) flash(u'你已不再关注 %s' % username) return redirect(url_for('.user', username=username))
def unfollow(username): user = User.query.filter_by(username=username).first() if user is None: flash('不存在的用户!') return redirect(url_for('.index')) if not current_user.is_following(user): flash('你并没有关注此用户!') return redirect(url_for('.user', username=username)) current_user.unfollow(user) flash('你对 %s 取消了关注。' % username) return redirect(url_for('.user', username=username))
def unfollow(username): user = User.query.filter_by(username=username).first() if user is None: flash('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))
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))
def unfollow(username): user = User.query.filter_by(username=username).first() if user is None: flash('Пользователь {} не найден'.format(username)) return redirect(url_for('index')) if user == current_user: flash('Вы не можете отписаться сами от себя!') return redirect(url_for('user', username=username)) current_user.unfollow(user) db.session.commit() flash('Вы больше не подписанны на {}'.format(username)) return redirect(url_for('user', username=username))
def unfollow(username): user = User.query.filter_by(username=username).first() if user is None: flash('User {} not found.'.format(username)) return redirect(url_for('index')) if user == current_user: flash('You cannot unfollow yourself!') return redirect(url_for('user', username=username)) current_user.unfollow(user) db.session.commit() flash('You are not following {}.'.format(username)) return redirect(url_for('user', username=username))
def unfollow(username): form = EmptyForm() if form.validate_on_submit(): user = User.query.filter_by(username=username).first() if user is None: flash(f'User {username} not found') return redirect(url_for('main.index')) elif user == current_user: flash('You can not unfollow yourself') return redirect(url_for('main.user', username=username)) current_user.unfollow(user) db.session.commit() flash(f'You are no longer following {username}') return redirect(url_for('main.user', username=username)) else: return redirect(url_for('main.index'))
def unfollow(username): form = EmptyForm() if form.validate_on_submit(): user = User.query.filter_by(username=username).first() if user is None: flash('User {} not found.'.format(username)) return redirect(url_for('index')) if user == current_user: flash('You cannot unfollow yourself!') return redirect(url_for('user', username=username)) current_user.unfollow(user) db.session.commit() flash('You are not following {}.'.format(username)) return redirect(url_for('user', username=username)) else: return redirect(url_for('index'))
def unfollow(username): form = EmptyForm() if form.validate_on_submit(): user = User.query.filter_by(username=username).first() if user is None: flash(f"User {username} is not found!") return redirect(url_for("index")) if user == current_user: flash("You can not unfollow yourself") return redirect(url_for("user", username=username)) current_user.unfollow(user) db.session.commit() flash(f"You have unfollowed {username}") return redirect(url_for("user", username=username)) else: return redirect(url_for("index"))
def unfollow(username): form = EmptyForm() if form.validate_on_submit(): user = User.query.filter_by(username=username).first() if user is None: flash(_('User %(username)s not found.', username=username)) return redirect(url_for('main.index')) if user == current_user: flash(_("You can't unfollow yourself!")) return redirect(url_for('main.user', username=username)) current_user.unfollow(user) db.session.commit() # pylint: disable=no-member flash(_('You are no longer following %(username)s.', username=username)) return redirect(url_for('main.user', username=username)) else: return redirect(url_for('main.index'))
def unfollow(username): form = EmptyForm() if form.validate_on_submit() : user = User.query.filter_by(username = username).first() if user is None: flash(_('User %(username)s not found', username = username)) return redirect(url_for('main.profile', username = username)) if user == current_user: flash(_('You cannot unfollow yourself')) return redirect(url_for('main.profile', username = username)) current_user.unfollow(user) db.session.commit() flash(_('You are not following %(username)s', username = username)) return redirect(url_for('main.profile', username = username)) else: return redirect(url_for('main.home'))
def unfollow(username): """ Unfollow a User """ user_ = User.query.filter_by(username=username).first() if user is None: flash('User {} not found.'.format(username)) return redirect(url_for('index')) if user_ == current_user: flash('You cannot unfollow yourself!') return redirect(url_for('user', username=username)) current_user.unfollow(user_) db.session.commit() flash('You are not following {}.'.format(username)) return redirect(url_for('main.user', username=username))
def unfollow(username): user = User.query.filter_by(username=username).first() if user is None: flash(_('User %(username)s not found', username=username)) return redirect(url_for('main.index')) if user == current_user: flash(_('The f**k you doing. You cannot unfollow yourself!')) return redirect('main.user', username=username) current_user.unfollow(user) db.session.commit() flash(_('You are not following %(username)s', username=username)) return redirect(url_for('main.user', username=username))
def unfollow(username): form = EmptyForm() if form.validate_on_submit(): user = User.query.filter_by(username=username).first() if user is None: flash(f'{username} not found.') return redirect(url_for('index')) if user == current_user: flash("You can't unfollow yourself!") return redirect(url_for('user', username=username)) current_user.unfollow(user) db.session.commit() flash(f'You no longer follow {username}') return redirect(url_for('user', username=username)) else: return redirect(url_for('index'))
def unfollow(username): """ :summary: 取消关注视图函数 :param username: :return: """ 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.users', username=username)) current_user.unfollow(user) flash('成功取消关注了用户%s' % username) return redirect(url_for('main.users', username=username))
def unfollow(username): form = EmptyForm() if form.validate_on_submit(): user = User.query.filter_by(username=username).first() if user is None: flash(f'User {username} not found') return redirect(url_for('main.index')) if user == current_user: flash('You cannot unfollow yourself!') return redirect(url_for('main.user',username=username)) current_user.unfollow(user) db.session.commit() flash(f'You are not followinng {username}') return redirect(url_for('main.user',username=username)) else: # validate_on_submit() 호출이 실패 할 수 있는 유일한 이유는 CSRF 토큰이 없거나 유효하지 않은 경우 return redirect(url_for('main.index')) # 이 경우 애플리케이션을 홈페이지로 다시 리디렉션함
def unfollow(username): user = User.query.filter_by(username=username).first() if (user is None): flash('User {} not found'.format(username)) return redirect(url_for('index')) elif (user == current_user): flash('You were not even following yourself!') return redirect(url_for('user', username=username)) else: current_user.unfollow(user) db.session.commit() flash('You are not following {}'.format(username)) return redirect(url_for('user', username=username))
def unfollow(handle): form = EmptyForm() # Empty form for CSRF protection if form.validate_on_submit(): user = models.User.query.filter_by(handle=handle).first() if user is None: flash('User {} not found.'.format(handle)) return redirect(url_for('index')) if user == current_user: flash('You cannot unfollow yourself!') return redirect(unquote(url_for('profile', handle=handle))) current_user.unfollow(user) db.session.commit() flash('You are not following {}.'.format(handle)) return redirect(unquote(url_for('profile', handle=handle))) else: return redirect(url_for('index'))
def unfollow(username): form = EmptyForm() if form.validate_on_submit(): user = User.query.filter_by(username=username).first() if user is None: flash(_('Пользователь %(username)s не найден.', username=username)) return redirect(url_for('main.index')) if user == current_user: flash(_('Вы не можете отписаться от себя!')) return redirect(url_for('main.user', username=username)) current_user.unfollow(user) db.session.commit() flash(_('Вы отписались от %(username)s.', username=username)) return redirect(url_for('main.user', username=username)) else: return redirect(url_for('main.index'))
def unfollow(username): form = FollowForm() if form.validate_on_submit(): user = User.query.filter_by(username=username).first() if user is None: flash("User {} is not found.".format(username)) return redirect(url_for('main.home')) elif user == current_user: flash("You cannot unfollow yourself.") return redirect(url_for('users.profile', username=user.username)) current_user.unfollow(user) db.session.commit() flash("You're no more following {}.".format(username)) return redirect(url_for('users.profile', username=user.username)) else: return redirect(url_for('main.home'))
def unfollow(username): """ Unfollow user to enable current user to unfollow a specified user with username :param username: the username to unfollow :return: a redirect to home page """ author = AuthorAccount.query.filter_by(username=username).first() if author is None: flash(message="Author %s not found" % username, category="error") return redirect(url_for("home.home")) if author == current_user: flash(message="You can't unfollow yourself!", category="error") return redirect(url_for("home.home")) u = current_user.unfollow(author) if u is None: flash(message="Cannot unfollow %s" % username, category="error") return redirect(url_for("home.home")) db.session.add(u) db.session.commit() flash(message="You are no longer following %s" % username, category="success") return redirect(url_for("home.home"))
def unfollow_topic(id): topic = Topic.query.get_or_404(id) if topic is None: flash('话题不存在', 'warning') return redirect(url_for('.index')) if topic.is_followed_by(current_user): current_user.unfollow(topic) topic_unfollow.send(topic) flash('取消关注了话题{}'.format(topic.title), 'info') if request.referrer == url_for('main.topics', _external=True): return redirect(url_for('main.topics')) else: return redirect(url_for('main.topic_detail', id=topic.id)) flash('你还没关注话题')
def unfollow(username): """ 取消follow :param username: :return: """ user = User.query.filter_by(username=username).first() if user is None: flash('User {} not found.'.format(username)) return redirect(url_for('index')) if user == current_user: flash("you can't unfollow yourself.") return redirect(url_for('main.user_home', username=username)) current_user.unfollow(user) db.session.commit() flash('you are not following {}.'.format(username)) return redirect(url_for('main.user_home', username=username))
def unfollow(username): """取消关注""" form = EmptyForm() if form.validate_on_submit(): user = User.query.filter_by(username=username).first() if user is None: flash('用户:{} 不存在'.format(username)) return redirect(url_for('main.index')) if user == current_user: flash('不能关注自己') return redirect(url_for('main.user', username=username)) current_user.unfollow(user) db.session.commit() flash('取消关注: {}'.format(username)) return redirect(url_for('main.user', username=username)) else: return redirect(url_for('main.index'))
def unfollow(username): ''' define operation of unfollow user :param username: username :return: page ''' user = User.query.filter_by(username=username).first() if user is None: flash(u'无效用户名') return redirect(url_for('index.index_page')) if not current_user.is_following(user): flash(u'你没有关注过这个用户!') return redirect(url_for('auth.user_detail', username=username)) current_user.unfollow(user) flash(u'您从现在起不再关注 %s 了.' % username) return redirect(url_for('auth.user_detail', username=username))
def unfollow(username): """ Usuwa danego użytkownika z obserwowanych dla aktualnie zalogowanego użytkownika :param username: user :return: przekierowanie do user lub index """ user_follow = User.query.filter_by(username=username).first() if user_follow is None: flash(_('User %(username)s not found.', username=username)) return redirect(url_for('main.index')) if user_follow == current_user: flash(_('You cannot unfollow yourself!')) return redirect(url_for('main.user', username=username)) current_user.unfollow(user_follow) db.session.commit() flash(_('You are not following %(username)s.', username=username)) return redirect(url_for('main.user', username=username))
def unfollow(username): form = EmptyForm() if form.validate_on_submit: user = User.query.filter_by(username=username).first() if user is None: flash('User {} cannot be found'.format(username)) return redirect(url_for('main.index')) if user == current_user: flash('You can not unfollow yourself, you know!') return redirect(url_for('main.user', username=username)) else: current_user.unfollow(user) db.session.commit() flash('You have unfollowed {}!'.format(username)) return redirect(url_for('main.user', username=username)) else: return redirect(url_for('main.index'))
def unfollow(username): user = User.query.filter_by(username=username).first() if user is None: flash("User does not exist!", "danger") return redirect(url_for("dashboard")) if user == current_user: flash('You cannot unfollow yourself!') return redirect(url_for('user', username=username)) current_user.unfollow(user) db.session.commit() flash("You are not following {}".format(username), "success") return redirect(url_for("userProfile", username=username))
def unfollow(event_id): #get event to be unfollowed event = Event.query.filter_by(id=event_id).first() #check if event exists if event is None: flash('Event {} - {} not found.'.format(event_id, event.event_name)) return redirect(url_for('auth.index')) #make user unfollow event current_user.unfollow(event) db.session.commit() flash('You have unfollowed this event: {}'.format(event.event_name)) #next_page functionality sourced from: #https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-v-user-logins next_page = request.args.get('next') if not next_page or url_parse(next_page).netloc != '': next_page = url_for('auth.index') return redirect(next_page)
def unfollow(username): form = EmptyForm() if form.validate_on_submit(): user = User.query.filter_by(username=username).first_or_404() if not user: flash(f'User {username} is not found', 'info') return redirect(url_for('index')) elif user == current_user: flash('You cannot unfollow yourself', 'info') return redirect(url_for('user', username=username)) else: current_user.unfollow(user) db.session.commit() flash(f'You are unfollowing {username}!', 'info') return redirect(url_for('user', username=username)) else: return redirect(url_for('index'))
def unfollow_by_id(userid): user = db.session\ .query(User)\ .filter_by(id=userid)\ .first() if user is None: flash('User not found.', category="danger") return redirect( url_for('profile.main', user_name=current_user.user_name)) if user == current_user: flash('You cannot unfollow yourself!', category="danger") return redirect(url_for('profile.main', user_name=user.user_name)) current_user.unfollow(user) db.session.commit() flash('You are not following', category="danger") return redirect( url_for('profile.profile_following_user', user_name=user.user_name))
def unfollow(username): '''route to allow users to unfollow another users post''' form = EmptyForm() if form.validate_on_submit(): user = User.query.filter_by(username=username).first() if user is None: #if there is no such user flash('User {} not found.'.format(username)) return redirect(url_for('main.index')) if user == current_user: #if the user is the current user flash('You cannot unfollow yourself!') return redirect(url_for('main.user', username=username)) current_user.unfollow(user) #otherwise allow user to unfollow user db.session.commit() flash('You are not following {}.'.format(username)) return redirect(url_for('main.user', username=username)) else: return redirect(url_for('main.index'))
def unfollow(username): user = User.query.filter_by(username=username).first() if user is None: flash(f"User {username} was not found") return redirect(url_for('home')) if user == current_user: flash('You cannot unfollow yourself!') return redirect(url_for('profile', username=username)) current_user.unfollow(user) db.session.commit() flash(f"You are no longer following {username}") return redirect(url_for('profile', username=username))
def unfollow(username): """ Dockydocstring """ #pylint: disable=redefined-outer-name user = User.query.filter_by(username=username).first() if user is None: flash('User {} not found.'.format(username)) return redirect(url_for('main.index')) if user == current_user: flash('You cannot unfollow yourself!') return redirect(url_for('main.user', username=username)) current_user.unfollow(user) db.session.commit() flash('You are not following {}.'.format(username)) return redirect(url_for('main.user', username=username))
def unfollow(username): user = User.query.filter_by(username=username).first() if user is None: flash(f'User {username} not found.') return redirect(url_for('index')) if user == current_user: flash('You cannot unfollow yourself!') return redirect(url_for('user', username=username)) current_user.unfollow(user) db.session.commit() flash(f'You ara not following {username}') return redirect(url_for('user', username=username))
def unfollow(username): # Look for username user = User.query.filter_by(username=username).first() # Checks if user is None: flash('User {} not found'.format(username)) return redirect(url_for('index')) if user == current_user: flash('You cannot unfollow yourself!') return redirect(url_for('user', username=username)) # Unfollow user current_user.unfollow(user) db.session.commit() flash('You are not following {}'.format(username)) return redirect(url_for('user', username=username))
def unfollow(username): form = EmptyForm() if form.validate_on_submit(): user = User.query.filter_by(username=username).first() if not user: flash(f"User {username} not found!") return redirect(url_for("main.index")) if user == current_user: flash(_("You cannot unfollow yourself!")) return redirect(url_for("main.user"), username=username) current_user.unfollow(user) db.session.commit() flash(_("You are no longer following %(username)s!", username=username)) return redirect(url_for("main.user", username=username)) else: return redirect(url_for("main.index"))