diff options
author | François Schmidts <francois.schmidts@gmail.com> | 2014-06-12 01:50:08 +0200 |
---|---|---|
committer | François Schmidts <francois.schmidts@gmail.com> | 2014-06-12 01:50:08 +0200 |
commit | 189daeb5862dcf6d89e5070c019cd584c26e73a6 (patch) | |
tree | 88226ddc308f24eb102cc9a88c0cbcfb9f1d2dfa /pyaggr3g470r/views.py | |
parent | aligning message box to the right (diff) | |
download | newspipe-189daeb5862dcf6d89e5070c019cd584c26e73a6.tar.gz newspipe-189daeb5862dcf6d89e5070c019cd584c26e73a6.tar.bz2 newspipe-189daeb5862dcf6d89e5070c019cd584c26e73a6.zip |
reimplementing the unread count in left menu
Diffstat (limited to 'pyaggr3g470r/views.py')
-rw-r--r-- | pyaggr3g470r/views.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index 2ad1ea5a..1b3be75e 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -36,7 +36,7 @@ from flask.ext.principal import Principal, Identity, AnonymousIdentity, \ identity_changed, identity_loaded, Permission,\ RoleNeed, UserNeed from flask.ext.babel import gettext -from sqlalchemy import desc +from sqlalchemy import desc, func from sqlalchemy.exc import IntegrityError from werkzeug import generate_password_hash @@ -227,11 +227,14 @@ def home(): if limit != 'all': limit = int(limit) articles = articles.limit(limit) + unread = db.session.query(Article.feed_id, func.count(Article.id))\ + .filter(Article.readed == False)\ + .group_by(Article.feed_id).all() def gen_url(filter_=filter_, limit=limit, feed=feed_id): return '/?filter_=%s&limit=%s&feed=%d' % (filter_, limit, feed) - return render_template('reader.html', gen_url=gen_url, feed_id=feed_id, + return render_template('home.html', gen_url=gen_url, feed_id=feed_id, filter_=filter_, limit=limit, feeds=feeds, - articles=articles.all()) + unread=dict(unread), articles=articles.all()) @app.route('/article/redirect/<int:article_id>', methods=['GET']) |