aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r
diff options
context:
space:
mode:
authorCédric Bonhomme <kimble.mandel@gmail.com>2014-02-06 13:52:18 +0100
committerCédric Bonhomme <kimble.mandel@gmail.com>2014-02-06 13:52:18 +0100
commit2e6af34ca2b4178c709b26c0e8a70c2de5916321 (patch)
treec035597b2337490b1f3e6343ab113b895c97efa5 /pyaggr3g470r
parentCheck if the number of articles is not greater than the parameter. (diff)
downloadnewspipe-2e6af34ca2b4178c709b26c0e8a70c2de5916321.tar.gz
newspipe-2e6af34ca2b4178c709b26c0e8a70c2de5916321.tar.bz2
newspipe-2e6af34ca2b4178c709b26c0e8a70c2de5916321.zip
Test if the id of the feed is valid.
Diffstat (limited to 'pyaggr3g470r')
-rw-r--r--pyaggr3g470r/views.py9
1 files changed, 8 insertions, 1 deletions
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/<feed_id>/<int:nb_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
bgstack15