aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/views.py
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2014-04-12 12:48:04 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2014-04-12 12:48:04 +0200
commitf10076577e4da7232596460bb7f9fef571b26536 (patch)
tree2926f57dd471a7713df9c4ff14fe5a67b7f46be0 /pyaggr3g470r/views.py
parentNew ForeignKey between Article and User. (diff)
downloadnewspipe-f10076577e4da7232596460bb7f9fef571b26536.tar.gz
newspipe-f10076577e4da7232596460bb7f9fef571b26536.tar.bz2
newspipe-f10076577e4da7232596460bb7f9fef571b26536.zip
Improvements of queries.
Diffstat (limited to 'pyaggr3g470r/views.py')
-rw-r--r--pyaggr3g470r/views.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py
index d7263cdd..22dedc58 100644
--- a/pyaggr3g470r/views.py
+++ b/pyaggr3g470r/views.py
@@ -236,8 +236,8 @@ def article(article_id=None):
"""
Presents the content of an article.
"""
- article = Article.query.filter(Article.id == article_id).first()
- if article != None and article.source.subscriber.id == g.user.id:
+ article = Article.query.filter(Article.user_id == g.user.id, Article.id == article_id).first()
+ if article != None:
if not article.readed:
article.readed = True
db.session.commit()
@@ -255,10 +255,10 @@ def mark_as_read(feed_id=None):
Mark all unreaded articles as read.
"""
if feed_id != None:
- Article.query.filter(Article.readed == False).join(Feed).filter(Feed.id == feed_id).update({"readed": True})
+ Article.query.filter(Article.user_id == g.user.id, Article.feed_id == feed_id, Article.readed == False).update({"readed": True})
flash('Articles marked as read.', 'info')
else:
- Article.query.filter(Article.readed == False).update({"readed": True})
+ Article.query.filter(Article.user_id == g.user.id, Article.readed == False).update({"readed": True})
flash("All articles marked as read", 'info')
db.session.commit()
return redirect(redirect_url())
@@ -269,8 +269,7 @@ def like(article_id=None):
"""
Mark or unmark an article as favorites.
"""
- #user = models.User.objects(email=g.user.email).first()
- Article.query.filter(Article.id == article_id). \
+ Article.query.filter(Article.user_id == g.user.id, Article.id == article_id). \
update({
"like": not Article.query.filter(Article.id == article_id).first().like
})
bgstack15