aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pyaggr3g470r/templates/home.html (renamed from pyaggr3g470r/templates/reader.html)10
-rw-r--r--pyaggr3g470r/views.py9
2 files changed, 15 insertions, 4 deletions
diff --git a/pyaggr3g470r/templates/reader.html b/pyaggr3g470r/templates/home.html
index a2b4481c..96cd83a5 100644
--- a/pyaggr3g470r/templates/reader.html
+++ b/pyaggr3g470r/templates/home.html
@@ -7,7 +7,15 @@
{{ _('All feeds') }}
{% if not feed_id %}</b>{% endif %}
</a></li>
- {% for fid, ftitle in feeds.items() %}
+ {% for fid in unread %}
+ <li><a href="{{ gen_url(feed=fid) }}">
+ {% if feed_id == fid %}<b>{% endif %}
+ <span class="badge pull-right">{{ unread[fid] }}</span>
+ {{ feeds[fid]|safe }}
+ {% if feed_id == fid %}</b>{% endif %}
+ </a></li>
+ {% endfor %}
+ {% for fid, ftitle in feeds.items() if not fid in unread %}
<li><a href="{{ gen_url(feed=fid) }}">
{% if feed_id == fid %}<b>{% endif %}
{{ ftitle|safe }}
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'])
bgstack15