Skip to content

Commit

Permalink
Ne sauvegarde pas le Topic si le premier Post est édité
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
philippemilink committed Oct 13, 2024
1 parent 53bc4d4 commit 3eb842f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 0 additions & 4 deletions zds/forum/commons.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
6 changes: 6 additions & 0 deletions zds/forum/tests/tests_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down

0 comments on commit 3eb842f

Please sign in to comment.