def follow(nickname): user = User.query.filter_by(nickname=nickname).first() # if the user doesn't exist if user is None: flash('User ' + nickname + ' not found.') return redirect(url_for('index')) # if the searched user is the logged in user if user == g.user: flash('You can\'t follow yourself!') return redirect(url_for('index')) # otherwise try to follow the user u = g.user.follow(user) # if it doesn't work for some reason, show an error message if u is None: flash('Cannot follow ' + nickname + '.') return redirect(url_for('index')) # commit changes and take us to their page db.session.add(u) db.session.commit() flash('You are now following ' + nickname + '!') follower_notification(user, g.user) return redirect(url_for('user', nickname=nickname))
def follow(nickname): user = User.query.filter_by(nickname=nickname).first() if user is None: flash('User ' + nickname + ' not found.') return redirect(url_for('index')) u = g.user.follow(user) if u is None: flash('Cannot follow ' + nickname + '.') return redirect(url_for('user', nickname=nickname)) db.session.add(u) db.session.commit() flash('You are now following ' + nickname + '!') follower_notification(user, g.user) return redirect(url_for('user', nickname=nickname))
def follow(nickname): user = User.query.filter_by(nickname = nickname).first() if user == None: flash(gettext('User ' + nickname + ' not found.')) return redirect(url_for('index')) if user == g.user: flash(gettext('You can\'t follow yourself!')) return redirect(url_for('user', nickname = nickname)) u = g.user.follow(user) if u is None: flash(gettext('Cannot follow ' + nickname + '.')) return redirect(url_for('user', nickname = nickname)) db.session.add(u) db.session.commit() follower_notification(user, g.user) return redirect(url_for('user', nickname = nickname))
def follow(nickname): user = User.query.filter_by(nickname=nickname).first() if user is None: flash('User %s not found' % nickname) return redirect(url_for('index')) if user == g.user: flash('You can\'t follow yourself') return redirect(url_for('user', nickname=nickname)) u = g.user.follow(user) if u is None: flash('Cannot follow %s.' % nickname) return redirect(url_for('user', nickname=nickname)) db.session.add(u) db.session.commit() flash('You are now following %s!' % nickname) follower_notification(user, g.user) return redirect(url_for('user', nickname=nickname))
def follow(nickname): user = User.query.filter_by(nickname=nickname).first() if user is None: flash('User {0} not fount'.format(nickname)) return redirect(url_for('index')) if user == g.user: flash("You can't follow yourself!") return redirect(url_for('user', nickname=nickname)) u = g.user.follow(user) if u is None: flash('Cannot follow {0}.'.format(nickname)) return redirect(url_for('user', nickname=nickname)) db.session.add(u) db.session.commit() flash('You are now following {0}!'.format(nickname)) follower_notification(user, g.user) return redirect(url_for('user', nickname=nickname))
def follow(nickname): user = User.query.filter_by(nickname=nickname).first() if user is None: flash('User %s not found.' % nickname) return redirect(url_for('index')) if user == g.user: flash('You can\'t follow yourself!') return redirect(url_for('user', nickname=nickname)) u = g.user.follow(user) if u is None: flash('Cannot follow ' + nickname + '.') return redirect(url_for('user', nickname=nickname)) db.session.add(u) db.session.commit() flash('You are now following ' + nickname + '!') follower_notification(user, g.user) return redirect(url_for('user', nickname=nickname))
def follow(nickname): user = User.query.filter_by(nickname=nickname).first() if user == None: flash("User {} is not found").format(nickname) return redirect(url_for(('index'))) if user == g.user: flash('You can\'t follow yourself!') return redirect(url_for('user', nickname=nickname)) u = g.user.follow(user) if u is None: flash('Cannot follow ' + nickname + '.') return redirect(url_for('user', nickname=nickname)) db.session.add(u) db.session.commit() flash('You are now following ' + nickname + '!') follower_notification(user, g.user) return redirect(url_for('user', nickname=nickname))
def follow(nickname): username = User.query.filter_by(nickname=nickname).first() if username is None: flash('User ' + nickname + ' not found.') return redirect(url_for('index')) if username == g.user: flash(gettext('You can\'t follow yourself!')) return redirect(url_for('user', nickname=nickname)) u = g.user.follow(username) if u is None: flash(gettext('Cannot follow %(nickname)s.', nickname=nickname)) return redirect(url_for('user', nickname=nickname)) db.session.add(u) db.session.commit() flash(gettext('You are now following %(nickname)s!', nickname=nickname)) follower_notification(username, g.user) return redirect(url_for('user', nickname=nickname))
def follow(nickname): user = User.query.filter_by(nickname=nickname).first() if user is None: flash("User {} not found".format(nickname)) return redirect(url_for("index")) if user == g.user: flash("You cannot follow yourself") return redirect(url_for("user", nickname=nickname)) u = g.user.follow(user) if u is None: flash("Cannot follow {}.".format(nickname)) return redirect(url_for("user", nickname=nickname)) db.session.add(u) db.session.commit() flash("You are following ().".format(nickname)) follower_notification(user, g.user) return redirect(url_for("user", nickname=nickname))
def follow(nickname): user = User.query.filter_by(nickname = nickname).first() if user is None: flash(gettext('用户 %(nickname)s 未找到。', nickname = nickname)) return redirect(url_for('index')) if user == g.user: flash(gettext('你不能关注自己!')) return redirect(url_for('user', nickname = nickname)) u = g.user.follow(user) if u is None: flash(gettext('不能关注 %(nickname)s', nickname = nickname)) return redirect(url_for('user', nickname = nickname)) db.session.add(u) db.session.commit() flash(gettext('目前你关注 %(nickname)s!', nickname = nickname)) follower_notification(user, g.user) return redirect(url_for('user', nickname = nickname))
def follow(username): user = User.query.filter_by(username=username).first() if user is None: flash('User ' + username + ' not found.') return redirect(url_for('index')) if user == g.user: flash('You can\'t follow yourself!') return redirect(url_for('user', username=username)) u = g.user.follow(user) if u is None: flash('Cannot follow ' + username + '.') return redirect(url_for('user', username=username)) db.session.add(u) db.session.commit() flash('You are now following ' + username + '!') follower_notification(user, g.user) return redirect(url_for('userprofile', username=g.user.username))
def follow(nickname): user = User.query.filter_by(nickname=nickname).first() if user == None: flash("User" + nickname + ' Not Found.') return redirect(url_for('index')) if user == g.user: flash("You Can't Follow Yourself") redirect(redirect(url_for('user', nickname=nickname))) u = g.user.follow(user) if u is None: flash('Cannot Follow ' + nickname + ".") redirect(redirect(url_for('user', nickname=nickname))) db.sesion.add(u) db.session.commit() flash('You are now following ' + nickname + '!') follower_notification(user, g.user) return redirect(url_for('user', nickname=nickname))
def follow(username): user = User.query.filter_by(username=username).first() if user is None: flash(gettext('User %(username)s not found.', username = username)) return redirect(url_for('index')) if user == g.user: flash(gettext('You can\'t follow yourself!')) return redirect(url_for('user', username=username)) u = g.user.follow(user) if u is None: flash(gettext('Cannot follow %(username)s.', username = username)) return redirect(url_for('user', username=username)) db.session.add(u) db.session.commit() flash(gettext('You are now following %(username)s!', username = username)) follower_notification(user, g.user) return redirect(url_for('user', username=username))
def followUser(nickname): user = User.query.filter_by(nickname = nickname).first() if user == None: flash('User ' + nickname + ' not found.', 'error') return redirect(url_for('home')) if user == g.user: flash('You can\'t follow yourself!', 'error') return redirect(url_for('user', nickname = nickname)) u = g.user.follow_user(user) if u is None: flash('Cannot follow ' + nickname + '.', 'error') return redirect(url_for('user', nickname = nickname)) db.session.add(u) db.session.commit() follower_notification(user, g.user) flash('You are now following ' + nickname + '!', 'info') return redirect(url_for('user', nickname = nickname))
def follow(nickname): user = User.query.filter_by(nickname=nickname).first() if user is None: flash('User ' + nickname + ' not found.') return redirect(url_for('index')) if user == g.user: flash('You can\'t follow yourself!') return redirect(url_for('user', nickname=nickname)) u = g.user.follow(user) if u is None: flash('Cannot follow ' + nickname + '.') return redirect(url_for('user', nickname=nickname)) db.session.add(u) db.session.commit() flash('You are now following ' + nickname + '!') # Call email function (emails.py) and pass followed & follower follower_notification(user, g.user) return redirect(url_for('user', nickname=nickname))
def follow(username): user = User.query.filter_by(username=username).first() if user == None: flash(gettext('User %(username)s not found.', usernmae = username)) #flash("User " + username + ' not found.') return redirect(url_for('home')) if user == g.user: flash(gettext("You can\'t follow yourself")) return redirect(url_for('user', user = user)) # link bitween g.user and user u = g.user.follow(user) if u is None: flash(gettext('Cannot follow %(username)s .', username=username)) return redirect(url_for('user', username=username)) db.session.add(u) db.session.commit() flash(gettext('You are now following %(username)s !', username=username)) follower_notification(user, g.user) return redirect(url_for('user', username=username))
def follow(nickname): user = User.query.filter_by(nickname = nickname).first() # check that the user exists if user == None: flash('User '+ nickname +' not found.') return redirect(url_for('index')) # check that the user is not you if user == g.user: flash('you can\'t follow yourself!') return redirect(url_for('user', nickname = nickname)) # try to follow the user u = g.user.follow(user) if u is None: flash('Cannot follow '+ nickname +'.') return redirect(url_for('user', nickname = nickname)) # everything checks out user properly followed # write it to the database db.session.add(u) db.session.commit() flash('You are now following '+ nickname +'!') follower_notification(user, g.user) return redirect(url_for('user', nickname = nickname))
def follow(nickname): user = User.query.filter_by(nickname = nickname).first() if user == None: flash('User ' + nickname + ' not found.') return redirect(url_for('index')) # Even though we set user as their own follower, they can't choose that if user == g.user: flash(gettext('You can\'t follow yourself!')) return redirect(url_for('user', nickname = nickname)) u = g.user.follow(user) if u is None: flash(gettext('Cannot follow %(nickname)s.', nickname = nickname)) return redirect(url_for('user', nickname = nickname)) db.session.add(u) db.session.commit() flash(gettext('You are now following %(nickname)s.', nickname = nickname)) follower_notification(user, g.user) return redirect(url_for('user', nickname = nickname))
def follow(nickname): user = User.query.filter_by(nickname=nickname).first() if user is None: flash('User not found') return redirect(url_for('index')) if user == g.user: flash('You cant follow yourself') return redirect(url_for('profile', nickname=nickname)) u = g.user.follow(user) # Something went wrong if u is None: flash('Unable to follow') return redirect(url_for('profile', nickname=nickname)) db.session.add(u) db.session.commit() flash('You are following %s' % nickname) follower_notification(user, g.user) return redirect(url_for('profile', nickname=nickname))
def follow(nickname): user = User.query.filter_by(nickname=nickname).first() # ... follower_notification(user, g.user) return redirect(url_for('user', nickname=nickname))
def follow(nickname): user = User.query.filter_by(nickname = nickname).first() # ... follower_notification(user, g.user) return redirect(url_for('user', nickname = nickname))