diff --git a/smash/views.py b/smash/views.py index 3156d33..f01fd39 100644 --- a/smash/views.py +++ b/smash/views.py @@ -51,15 +51,22 @@ def login_page(): def latest(): quotes = Quote.query.filter_by(approved=True).order_by(Quote.id.desc()).all() - # Replace line breaks with html breaks and escape special characters - for quote in quotes: - quote.content = str(Markup.escape(quote.content)).replace('\n', '
') + if len(quotes)>0: + # Replace line breaks with html breaks and escape special characters + for quote in quotes: + quote.content = str(Markup.escape(quote.content)).replace('\n', '
') - return render_template( - "latest.html", - title="Latest", - quotes=quotes - ) + return render_template( + "latest.html", + title="Latest", + quotes=quotes + ) + else: + return render_template( + "message.html", + alertclass="alert-warning", + message="No quotes in the database. " + ) @app.route('/queue')