From 2e6af34ca2b4178c709b26c0e8a70c2de5916321 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Thu, 6 Feb 2014 13:52:18 +0100 Subject: Test if the id of the feed is valid. --- pyaggr3g470r/views.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'pyaggr3g470r') diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index 668ec141..33be7d7d 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -246,7 +246,11 @@ def delete(article_id=None): @app.route('/articles//', methods=['GET']) @login_required def articles(feed_id=None, nb_articles=-1): - user = models.User.objects(email=g.user.email, feeds__oid=feed_id).first() + try: + user = models.User.objects(email=g.user.email, feeds__oid=feed_id).first() + except: + flash("No such feed.", "danger") + return redirect(url_for('home')) for feed in user.feeds: if str(feed.oid) == feed_id: if len(feed.articles) <= nb_articles: @@ -254,6 +258,9 @@ def articles(feed_id=None, nb_articles=-1): if nb_articles != -1: feed.articles = feed.articles[0:nb_articles] return render_template('articles.html', feed=feed, nb_articles=nb_articles) + else: + flash("No such feed.", "error") + return redirect(url_for('home')) @app.route('/favorites/', methods=['GET']) @login_required -- cgit