From d84e10ac976c38e95f340b397d566e8ac3e89c39 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Sat, 2 Nov 2013 17:42:31 +0100 Subject: Bugfix when deleting an entire feed. --- pyaggr3g470r/models.py | 4 ++++ pyaggr3g470r/views.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'pyaggr3g470r') diff --git a/pyaggr3g470r/models.py b/pyaggr3g470r/models.py index 82c0be15..1234b0a8 100644 --- a/pyaggr3g470r/models.py +++ b/pyaggr3g470r/models.py @@ -43,6 +43,10 @@ class Feed(EmbeddedDocument): 'ordering': ['+title'] } + def __eq__(self, other): + return self.title == other.title + + def __str__(self): return 'Feed: %s' % self.title diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index 9b940381..f93f276f 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -129,7 +129,7 @@ def delete(article_id=None): @app.route('/delete_feed/', methods=['GET']) @login_required def delete_feed(feed_id=None): - user = models.User.objects(email=g.user.email, feeds__oid=feed_id).first() + user = models.User.objects(email=g.user.email).first() # delete all articles (Document objects) for feed in user.feeds: if str(feed.oid) == feed_id: @@ -137,7 +137,7 @@ def delete_feed(feed_id=None): 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.feeds.remove(feed) user.save() return redirect(url_for('home')) -- cgit