def stream(username=None): template = 'stream.html' if username and username != current_user.username: try: user = models.User.select().where( models.User.username**username).get() except models.DoesNotExist: app.logger.info( "No user named " + username + " was found in the database. A 404 error was raised.") abort(404) else: stream = user.posts.limit(100) this_route = url_for('.stream') app.logger.info(current_user.username + " viewed " + username + "'s Stream section " + this_route) else: stream = current_user.get_stream().limit(100) user = current_user this_route = url_for('.stream') app.logger.info(current_user.username + " viewed his/her Stream section " + this_route) if username: template = 'user-stream.html' return render_template(template, stream=stream, user=user)
def stream(username=None): template = 'stream.html' if username and username != current_user.username: user = models.User.select().where(models.User.username**username).get() stream = user.posts.limit(100) else: stream = current_user.get_stream().limit(100) user = current_user if username: template = 'user_stream.html' return render_template(template, stream=stream, user=user)
def stream(username=None): template = 'stream.html' if username and username != current_user.username: user = models.User.select().where(models.User.username**username) stream = user.post.limit(100) else: stream = current_user.get_stream().limit(100) user = current_user if username: template = 'user_stream.html' return render_template(template, stream=stream, user=user)
def stream(username=none): template = 'stream.html' if username and username != current_user.username: user = models.User.select().where(models.User.username**username).get() # the ** is the "like" operator (non-case sensitive comparison) stream = user.posts.limit(100) else: stream = current_user.get_stream().limit(100) user = current_user if username: template = 'user_stream.html' return render_template(template, stream=stream, user=user)
def stream(username=none): template = 'stream.html' if username and username != current_user.username: user = models.User.select().where(models.User.username**username).get( ) # the ** is the "like" operator (non-case sensitive comparison) stream = user.posts.limit(100) else: stream = current_user.get_stream().limit(100) user = current_user if username: template = 'user_stream.html' return render_template(template, stream=stream, user=user)
def stream(username=None): template = 'stream.html' if username and username != current_user.username: try: user = models.User.select().where(models.User.username**username).get() stream = user.posts.limit(100) except model.DoesNotExist: abort(404) else: stream = current_user.get_stream().limit(100) user = current_user if username: template = 'user_stream.html' return render_template(template, stream=stream, user=user)
def stream(username = None): template = 'stream.html' if username and username != current_user.username: try: user = models.User.select().where( models.User.username**username).get() #** is the 'like' operator except models.DoesNotExist: abort(404) else: stream = user.posts.limit(100) else: stream = current_user.get_stream().limit(100) user = current_user if username: template = 'user_stream.html' return render_template(template, stream = stream, user = user)
def streaming(username=None): template = 'stream.html' user = current_user stream = [] if user.is_authenticated(): stream = current_user.get_stream().limit(100) if username and username != current_user.username: try: user = models.User.select().where( models.User.username ** username).get() except models.DoesNotExist: abort(404) else: stream = user.posts.limit(100) if username: template = 'user_stream.html' return render_template(template, stream=stream, user=user)
def stream(username=None): template = 'stream.html' current_user = g.user._get_current_object() print "Current user is %s" % current_user.get_id() if username and username != current_user.username: try: user = models.User.select().where( models.User.username**username).get() # ** ignores case except models.DoesNotExist: abort(404) else: stream = user.posts.limit(100) else: stream = current_user.get_stream().limit(100) user = current_user if username: template = 'user_stream.html' return render_template(template, stream=stream, user=user)
def stream(username=None): try: user = current_user.username except: flash("You must be logged in to view a user's stream!", "success") return redirect(url_for('login')) else: template = 'stream.html' if username and username != current_user.username: try: user = models.User.select().where( models.User.username**username).get() except models.DoesNotExist: abort(404) # if user does not exist send error else: stream = user.posts.limit(100) else: stream = current_user.get_stream().limit(100) user = current_user if username: template = 'user_stream.html' return render_template(template, stream=stream, user=user)