From f8924883291289cd68418b3c2dadcc4f5458ff81 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Sun, 12 Jan 2014 10:42:21 +0100 Subject: Keep the MongoDB database and Whoosh index synchronized. --- pyaggr3g470r/views.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'pyaggr3g470r') diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index 34cdcea7..b0977c65 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -200,7 +200,8 @@ def like(article_id=None): @login_required def delete(article_id=None): """ - Delete an article. + Delete an article from the MongoDB and the Whoosh + databases. """ user = models.User.objects(email=g.user.email).first() # delete the article @@ -210,6 +211,11 @@ def delete(article_id=None): feed.articles.remove(article) article.delete() user.save() + try: + fastsearch.delete_article(str(feed.oid), str(article.id)) + except: + # if index is empty + pass flash('Article "' + article.title + '" deleted.', 'success') return redirect(url_for('home')) flash('Impossible to delete the article.', 'danger') -- cgit