From 90d9b7fcb076160f51ac528575d994cf201ffa46 Mon Sep 17 00:00:00 2001 From: nukeop Date: Mon, 2 Jan 2017 15:08:55 +0100 Subject: [PATCH] Add a message if there are no quotes. --- smash/views.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/smash/views.py b/smash/views.py index 839080a..3156d33 100644 --- a/smash/views.py +++ b/smash/views.py @@ -66,15 +66,22 @@ def latest(): def queue(): quotes = Quote.query.filter_by(approved=False).order_by(Quote.id).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( - "queue.html", - title="Queue", - quotes=quotes - ) + return render_template( + "queue.html", + title="Queue", + quotes=quotes + ) + else: + return render_template( + "message.html", + alertclass="alert-warning", + message="No quotes in the database. " + ) @app.route('/quote/')