aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pyaggr3g470r/templates/favorites.html7
-rw-r--r--pyaggr3g470r/templates/unread.html7
-rw-r--r--pyaggr3g470r/views.py14
3 files changed, 22 insertions, 6 deletions
diff --git a/pyaggr3g470r/templates/favorites.html b/pyaggr3g470r/templates/favorites.html
index fb0b3220..1af2e327 100644
--- a/pyaggr3g470r/templates/favorites.html
+++ b/pyaggr3g470r/templates/favorites.html
@@ -2,8 +2,13 @@
{% block content %}
<div class="container">
{% if feeds|count == 0 %}
- <h1>No favorites.</h1>
+ <div class="page-header">
+ <h1>No favorites</h1>
+ </div>
{% else %}
+ <div class="page-header">
+ <h1>Favorites articles <small>{{ nb_favorites }}</small></h1>
+ </div>
{% for feed in feeds|sort(attribute="title") %}
<div class="row">
<div class="col-md-6 col-md-offset-3">
diff --git a/pyaggr3g470r/templates/unread.html b/pyaggr3g470r/templates/unread.html
index ed6aae19..41c89a29 100644
--- a/pyaggr3g470r/templates/unread.html
+++ b/pyaggr3g470r/templates/unread.html
@@ -2,8 +2,13 @@
{% block content %}
<div class="container">
{% if feeds|count == 0 %}
- <h1>No unread articles.</h1>
+ <div class="page-header">
+ <h1>No unread articles</h1>
+ </div>
{% else %}
+ <div class="page-header">
+ <h1>Unread articles <small>{{ nb_unread }}</small></h1>
+ </div>
{% for feed in feeds|sort(attribute="title") %}
<div class="row">
<div class="col-md-6 col-md-offset-3">
diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py
index b53b03c3..78508179 100644
--- a/pyaggr3g470r/views.py
+++ b/pyaggr3g470r/views.py
@@ -239,11 +239,14 @@ def favorites():
"""
user = models.User.objects(email=g.user.email).first()
result = []
+ nb_favorites = 0
for feed in user.feeds:
feed.articles = [article for article in feed.articles if article.like]
- if len(feed.articles) != 0:
+ length = len(feed.articles)
+ if length != 0:
result.append(feed)
- return render_template('favorites.html', feeds=result)
+ nb_favorites += length
+ return render_template('favorites.html', feeds=result, nb_favorites=nb_favorites)
@app.route('/unread/', methods=['GET'])
@login_required
@@ -253,11 +256,14 @@ def unread():
"""
user = models.User.objects(email=g.user.email).first()
result = []
+ nb_unread = 0
for feed in user.feeds:
feed.articles = [article for article in feed.articles if not article.readed]
- if len(feed.articles) != 0:
+ length = len(feed.articles)
+ if length != 0:
result.append(feed)
- return render_template('unread.html', feeds=result)
+ nb_unread += length
+ return render_template('unread.html', feeds=result, nb_unread=nb_unread)
@app.route('/inactives/', methods=['GET'])
@login_required
bgstack15