aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/views.py
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2014-04-08 19:41:49 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2014-04-08 19:41:49 +0200
commitd67f2dc496fc9b072b1fe26fdc3ec7b926efbbd7 (patch)
tree9a75b04374a5cbeab1fa94c95eb9fb32162989a8 /pyaggr3g470r/views.py
parentImproved articles loading for the home page. (diff)
downloadnewspipe-d67f2dc496fc9b072b1fe26fdc3ec7b926efbbd7.tar.gz
newspipe-d67f2dc496fc9b072b1fe26fdc3ec7b926efbbd7.tar.bz2
newspipe-d67f2dc496fc9b072b1fe26fdc3ec7b926efbbd7.zip
Mark all articles (or all articles from a feed) as read.
Diffstat (limited to 'pyaggr3g470r/views.py')
-rw-r--r--pyaggr3g470r/views.py19
1 files changed, 6 insertions, 13 deletions
diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py
index c2f6b9bf..9be985c9 100644
--- a/pyaggr3g470r/views.py
+++ b/pyaggr3g470r/views.py
@@ -249,27 +249,20 @@ 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'])
+@app.route('/mark_as_read/<int:feed_id>', methods=['GET'])
@login_required
+@feed_access_required
def mark_as_read(feed_id=None):
"""
Mark all unreaded articles as read.
"""
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()
- flash('Articles of the feed "' + feed.title + '" marked as read.', 'info')
- break
- else:
- flash("This feed do not exist.", 'warning')
+ articles, feed = Article.query.filter(Article.readed == False).join(Feed).filter(Feed.id == feed_id).update({"readed": True})
+ flash('Articles marked as read.', 'info')
else:
- models.Article.objects(readed=False).update(set__readed=True)
+ Article.query.filter(Article.readed == False).update({"readed": True})
flash("All articles marked as read", 'info')
+ db.session.commit()
return redirect(redirect_url())
@app.route('/like/<article_id>', methods=['GET'])
bgstack15