diff options
author | Cédric Bonhomme <kimble.mandel@gmail.com> | 2013-11-01 17:35:22 +0100 |
---|---|---|
committer | Cédric Bonhomme <kimble.mandel@gmail.com> | 2013-11-01 17:35:22 +0100 |
commit | c5cc3e6d3f1dff98cdac855d7399b9fe8235cfef (patch) | |
tree | 1d5c5154787d072197d3429568a912fc88b68ad9 /pyaggr3g470r/views.py | |
parent | Improved sort of feeds. (diff) | |
download | newspipe-c5cc3e6d3f1dff98cdac855d7399b9fe8235cfef.tar.gz newspipe-c5cc3e6d3f1dff98cdac855d7399b9fe8235cfef.tar.bz2 newspipe-c5cc3e6d3f1dff98cdac855d7399b9fe8235cfef.zip |
It is now possible to delete an article or an entire feed.
Diffstat (limited to 'pyaggr3g470r/views.py')
-rw-r--r-- | pyaggr3g470r/views.py | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index 0d6fcf21..9b940381 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -116,10 +116,30 @@ def article(article_id=None): @app.route('/delete/<article_id>', methods=['GET']) @login_required def delete(article_id=None): - article = models.Article.objects(id=article_id).first() - article.delete() - article.save() - return redirect(url_for('home')) + user = models.User.objects(email=g.user.email).first() + # delete the article + for feed in user.feeds: + for article in feed.articles: + if str(article.id) == article_id: + feed.articles.remove(article) + article.delete() + user.save() + return redirect(url_for('home')) + +@app.route('/delete_feed/<feed_id>', methods=['GET']) +@login_required +def delete_feed(feed_id=None): + user = models.User.objects(email=g.user.email, feeds__oid=feed_id).first() + # delete all articles (Document objects) + for feed in user.feeds: + if str(feed.oid) == feed_id: + for article in feed.articles: + article.delete() + feed.articles = [] + # delete the feed (EmbeddedDocument object) + models.User.objects(email=g.user.email, feeds__oid=feed_id).update_one(pull__feeds__oid = feed_id) + user.save() + return redirect(url_for('home')) @app.route('/articles/<feed_id>', methods=['GET']) @login_required |