From 3eb842f33d68147c8b44ccd7313fa3316b3a2aa7 Mon Sep 17 00:00:00 2001 From: Philippe MILINK Date: Sat, 5 Oct 2024 18:32:18 +0200 Subject: [PATCH] =?UTF-8?q?Ne=20sauvegarde=20pas=20le=20Topic=20si=20le=20?= =?UTF-8?q?premier=20Post=20est=20=C3=A9dit=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit C'était fait pour indiquer qu'il faut réindexer le Topic, mais dans la nouvelle version du système de recherche (passage de ElasticSearch à Typesense), aucune information indexée pour un Topic ne change si on modifie le premier Post du Topic, sauvegarder le Topic est donc inutile. En plus, ajout d'un test pour s'assurer que la modification d'un Post (ce qui crée un CommentEdit), marque bien le Post comme à indexer. --- zds/forum/commons.py | 4 ---- zds/forum/tests/tests_views.py | 6 ++++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/zds/forum/commons.py b/zds/forum/commons.py index 83ed110f78..254c48b47b 100644 --- a/zds/forum/commons.py +++ b/zds/forum/commons.py @@ -176,10 +176,6 @@ def perform_edit_post(request, post, user, text): post.editor = user post.save() - # Save topic to update update_index_date - if post.position == 1: - post.topic.save() - return post diff --git a/zds/forum/tests/tests_views.py b/zds/forum/tests/tests_views.py index 1f7ee5fa23..b73889ec0a 100644 --- a/zds/forum/tests/tests_views.py +++ b/zds/forum/tests/tests_views.py @@ -1518,6 +1518,8 @@ def test_creation_archive_on_edit(self): topic = create_topic_in_forum(forum, profile) post_before_edit = Post.objects.get(pk=topic.last_message.pk) + post_before_edit.save(search_engine_requires_index=False) + edits_count = CommentEdit.objects.count() # Edit post @@ -1537,6 +1539,10 @@ def test_creation_archive_on_edit(self): self.assertEqual(post_before_edit.text, edit.original_text) self.assertEqual(profile.user, edit.editor) + # Check the post was marked as to reindex + post_before_edit.refresh_from_db() + self.assertTrue(post_before_edit.search_engine_requires_index) + class PostUsefulTest(TestCase): def test_failure_post_useful_require_method_post(self):