From 646da3d66a457cb852a7ebf8a9d0b03b7bc272a1 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Fri, 23 May 2014 11:03:46 +0200 Subject: Display unread articles for one feed. --- pyaggr3g470r/views.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'pyaggr3g470r') diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index f73ba812..24175024 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -403,13 +403,17 @@ def favorites(): nb_favorites += length return render_template('favorites.html', feeds=result, nb_favorites=nb_favorites) +@app.route('/unread//', methods=['GET']) @app.route('/unread/', methods=['GET']) @login_required -def unread(): +def unread(feed_id=None): """ List unread articles. """ - feeds_with_unread = Feed.query.filter(Feed.user_id == g.user.id, Feed.articles.any(readed=False)) + if feed_id is not None: + feeds_with_unread = Feed.query.filter(Feed.user_id == g.user.id, Feed.id == feed_id) + else: + feeds_with_unread = Feed.query.filter(Feed.user_id == g.user.id, Feed.articles.any(readed=False)) result, nb_unread = [], 0 for feed in feeds_with_unread: new_feed = Feed() -- cgit