diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2014-04-08 19:49:31 +0200 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2014-04-08 19:49:31 +0200 |
commit | 198cb498e0fdbc5d7f7471ba980d2ab69574fd3b (patch) | |
tree | 53c49f431d783c1d04af8489ce81779af305b930 | |
parent | Fix. (diff) | |
download | newspipe-198cb498e0fdbc5d7f7471ba980d2ab69574fd3b.tar.gz newspipe-198cb498e0fdbc5d7f7471ba980d2ab69574fd3b.tar.bz2 newspipe-198cb498e0fdbc5d7f7471ba980d2ab69574fd3b.zip |
Like/unlike articles.
-rw-r--r-- | pyaggr3g470r/views.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index 551abba2..451d6b56 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -239,7 +239,7 @@ def article(article_id=None): Presents the content of an article. """ article = Article.query.filter(Article.id == article_id).first() - if article.feed.subscriber.id == g.user.id: + if article.source.subscriber.id == g.user.id: if article == None: flash("This article do not exist.", 'warning') return redirect(redirect_url()) @@ -265,15 +265,18 @@ def mark_as_read(feed_id=None): db.session.commit() return redirect(redirect_url()) -@app.route('/like/<article_id>', methods=['GET']) +@app.route('/like/<int:article_id>', methods=['GET']) @login_required def like(article_id=None): """ Mark or unmark an article as favorites. """ #user = models.User.objects(email=g.user.email).first() - models.Article.objects(id=article_id).update(set__like= \ - (not models.Article.objects(id=article_id).first().like)) + Article.query.filter(Article.id == article_id). \ + update({ + "like": not Article.query.filter(Article.id == article_id).first().like + }) + db.session.commit() return redirect(redirect_url()) @app.route('/delete/<article_id>', methods=['GET']) |