diff options
Diffstat (limited to 'pyaggr3g470r/views.py')
-rw-r--r-- | pyaggr3g470r/views.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index 24175024..ec3fcf35 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -213,8 +213,9 @@ def home(): The home page lists most recent articles of all feeds. """ user = User.query.filter(User.email == g.user.email).first() - result = [] + result, unread = [], {} for feed in user.feeds: + unread[feed.id] = Article.query.filter(Article.user_id == g.user.id, Article.feed_id == feed.id, Article.readed == False).count() new_feed = Feed() new_feed.id = feed.id new_feed.title = feed.title @@ -223,7 +224,7 @@ def home(): Article.feed_id == feed.id).order_by(desc("Article.date")).limit(9) result.append(new_feed) unread_articles = len(Article.query.filter(Article.user_id == g.user.id, Article.readed == False).all()) - return render_template('home.html', result=result, head_title=unread_articles) + return render_template('home.html', result=result, unread=unread, head_title=unread_articles) @app.route('/fetch/', methods=['GET']) @app.route('/fetch/<int:feed_id>', methods=['GET']) |