aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/views.py
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2014-02-02 10:14:09 +0100
committerCédric Bonhomme <cedric@cedricbonhomme.org>2014-02-02 10:14:09 +0100
commit1b50120f823f493a0ab02cd25b099b7b786bf20c (patch)
tree7a3749d40239a18df1e1539e298a57b1885c8a8c /pyaggr3g470r/views.py
parentTest with another time format (only for the home page). (diff)
downloadnewspipe-1b50120f823f493a0ab02cd25b099b7b786bf20c.tar.gz
newspipe-1b50120f823f493a0ab02cd25b099b7b786bf20c.tar.bz2
newspipe-1b50120f823f493a0ab02cd25b099b7b786bf20c.zip
Mark all articles as read by feed.
Diffstat (limited to 'pyaggr3g470r/views.py')
-rw-r--r--pyaggr3g470r/views.py15
1 files changed, 12 insertions, 3 deletions
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