aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pyaggr3g470r/templates/home.html1
-rw-r--r--pyaggr3g470r/templates/unread.html1
-rw-r--r--pyaggr3g470r/views.py15
3 files changed, 14 insertions, 3 deletions
diff --git a/pyaggr3g470r/templates/home.html b/pyaggr3g470r/templates/home.html
index 9ea8c01a..25cb5012 100644
--- a/pyaggr3g470r/templates/home.html
+++ b/pyaggr3g470r/templates/home.html
@@ -14,6 +14,7 @@
{% if feed.enabled %}
<a href="/fetch/{{ feed.oid }}"><i class="glyphicon glyphicon-cloud-download" title="Fetch this feed"></i></a>
{% endif %}
+ <a href="/mark_as_read/{{ feed.oid }}"><i class="glyphicon glyphicon-check" title="Mark all as read"></i></a>
</div>
</div>
{% for number in range(0, feed.articles|length-(feed.articles|length % 3), 3) %}
diff --git a/pyaggr3g470r/templates/unread.html b/pyaggr3g470r/templates/unread.html
index 41c89a29..9058182c 100644
--- a/pyaggr3g470r/templates/unread.html
+++ b/pyaggr3g470r/templates/unread.html
@@ -16,6 +16,7 @@
<a href="/articles/{{ feed.oid }}"><i class="glyphicon glyphicon-th-list" title="All articles"></i></a>
<a href="/feed/{{ feed.oid }}"><i class="glyphicon glyphicon-info-sign" title="Details"></i></a>
<a href="/edit_feed/{{ feed.oid }}"><i class="glyphicon glyphicon-edit" title="Edit this feed"></i></a>
+ <a href="/mark_as_read/{{ feed.oid }}"><i class="glyphicon glyphicon-check" title="Mark all as read"></i></a>
<h3>{{ feed.articles|length }} unread articles.</h3>
</div>
</div>
diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py
index 78508179..ee163099 100644
--- a/pyaggr3g470r/views.py
+++ b/pyaggr3g470r/views.py
@@ -178,13 +178,22 @@ def article(article_id=None):
return render_template('article.html', head_title=utils.clear_string(article.title), article=article)
@app.route('/mark_as_read/', methods=['GET'])
+@app.route('/mark_as_read/<feed_id>', methods=['GET'])
@login_required
-def mark_as_read():
+def mark_as_read(feed_id=None):
"""
Mark all unreaded articles as read.
"""
- #user = models.User.objects(email=g.user.email).first()
- models.Article.objects(readed=False).update(set__readed=True)
+ if feed_id != None:
+ user = models.User.objects(email=g.user.email).first()
+ for feed in user.feeds:
+ if str(feed.oid) == feed_id:
+ unread_articles = [article for article in feed.articles if not article.readed]
+ for article in unread_articles:
+ article.readed = True
+ article.save()
+ else:
+ models.Article.objects(readed=False).update(set__readed=True)
return redirect(url_for('home'))
@app.route('/like/<article_id>', methods=['GET'])
bgstack15