aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r
diff options
context:
space:
mode:
Diffstat (limited to 'pyaggr3g470r')
-rw-r--r--pyaggr3g470r/templates/home.html4
-rw-r--r--pyaggr3g470r/views/views.py13
2 files changed, 13 insertions, 4 deletions
diff --git a/pyaggr3g470r/templates/home.html b/pyaggr3g470r/templates/home.html
index a31d65e1..0b45996c 100644
--- a/pyaggr3g470r/templates/home.html
+++ b/pyaggr3g470r/templates/home.html
@@ -8,9 +8,9 @@
{% else %}
<div id="affix-nav" class="col-md-3 sidebar hidden-xs hidden-sm">
<ul class="nav sidenav navbar-collapse pre-scrollable" data-offset-top="0" data-offset-bottom="0" style="min-height: 650px;">
- <li><a href="{{ gen_url(feed=0) }}">
+ <li><a href="{{ gen_url(feed_id=0) }}">
{% if not feed_id %}<b>{% endif %}
- {{ _('All feeds') }} <span id="total-unread" class="badge pull-right">{{ articles.__len__() }}</span>
+ {{ _('All feeds') }} <span id="total-unread" class="badge pull-right">{{ unread.items()|sum(attribute="1") }} / {{ articles.__len__() }}</span>
{% if not feed_id %}</b>{% endif %}
</a></li>
{% for fid, nbunread in unread|dictsort(by='value')|reverse %}
diff --git a/pyaggr3g470r/views/views.py b/pyaggr3g470r/views/views.py
index c1e96bc4..658276c0 100644
--- a/pyaggr3g470r/views/views.py
+++ b/pyaggr3g470r/views/views.py
@@ -245,7 +245,6 @@ def render_home(filters=None, head_titles=None,
arti_contr = ArticleController(g.user.id)
feeds = {feed.id: feed.title for feed in feed_contr.read()}
- unread = arti_contr.get_unread()
in_error = {feed.id: feed.error_count for feed in
feed_contr.read(error_count__gt=2)}
@@ -268,9 +267,19 @@ def render_home(filters=None, head_titles=None,
}.get(sort_, Article.date.desc())
articles = arti_contr.read(**filters).order_by(sort_param)
+ unread_counter = {}
if limit != 'all':
limit = int(limit)
articles = articles.limit(limit)
+ {article.feed_id: 1
+ if article.feed_id not in unread_counter and
+ not unread_counter.update({article.feed_id: 1})
+ else unread_counter[article.feed_id] + 1
+ if not unread_counter.update({article.feed_id:
+ unread_counter[article.feed_id] + 1})
+ else 1
+ for article in articles if article.readed==False
+ }
def gen_url(filter_=filter_, sort_=sort_, limit=limit, feed_id=feed_id,
**kwargs):
@@ -291,7 +300,7 @@ def render_home(filters=None, head_titles=None,
return render_template('home.html', gen_url=gen_url, feed_id=feed_id,
filter_=filter_, limit=limit, feeds=feeds,
- unread=unread, articles=articles, in_error=in_error,
+ unread=unread_counter, articles=articles, in_error=in_error,
head_titles=head_titles, sort_=sort_, **kwargs)
bgstack15