diff --git a/lacommunaute/forum/models.py b/lacommunaute/forum/models.py index ca4f1123a..d68fa15ea 100644 --- a/lacommunaute/forum/models.py +++ b/lacommunaute/forum/models.py @@ -65,12 +65,6 @@ def is_in_documentation_area(self): def is_toplevel_discussion_area(self): return self == Forum.objects.get_main_forum() - def get_session_rating(self, session_key): - return getattr(ForumRating.objects.filter(forum=self, session_id=session_key).first(), "rating", None) - - def get_average_rating(self): - return ForumRating.objects.filter(forum=self).aggregate(models.Avg("rating"))["rating__avg"] - # TODO : to be removed after migration class ForumRating(DatedModel): diff --git a/lacommunaute/forum/tests/tests_model.py b/lacommunaute/forum/tests/tests_model.py index dcd0a13ab..33aeaca62 100644 --- a/lacommunaute/forum/tests/tests_model.py +++ b/lacommunaute/forum/tests/tests_model.py @@ -1,7 +1,7 @@ from django.conf import settings from django.test import TestCase -from lacommunaute.forum.factories import CategoryForumFactory, ForumFactory, ForumRatingFactory +from lacommunaute.forum.factories import CategoryForumFactory, ForumFactory from lacommunaute.forum.models import Forum from lacommunaute.forum_conversation.factories import TopicFactory from lacommunaute.users.factories import UserFactory @@ -72,23 +72,6 @@ def test_is_toplevel_discussion_area(self): self.assertFalse(forum.is_toplevel_discussion_area) self.assertFalse(sub_forum.is_toplevel_discussion_area) - def test_get_session_rating(self): - forum = ForumFactory() - forum_rating = ForumRatingFactory(forum=forum) - - self.assertIsNone(forum.get_session_rating("test")) - self.assertEqual(forum.get_session_rating(forum_rating.session_id), forum_rating.rating) - - ForumRatingFactory(forum=forum, session_id=forum_rating.session_id, rating=forum_rating.rating + 1) - self.assertEqual(forum.get_session_rating(forum_rating.session_id), forum_rating.rating + 1) - - def test_get_average_rating(self): - forum = ForumFactory() - ForumRatingFactory(forum=forum, rating=1) - ForumRatingFactory(forum=forum, rating=5) - - self.assertEqual(forum.get_average_rating(), 3) - class TestForumQueryset: def test_get_main_forum_wo_forum(self, db): diff --git a/lacommunaute/forum/tests/tests_views.py b/lacommunaute/forum/tests/tests_views.py index 17acc2013..eb0ad8d8f 100644 --- a/lacommunaute/forum/tests/tests_views.py +++ b/lacommunaute/forum/tests/tests_views.py @@ -82,7 +82,6 @@ def test_context(self): self.assertEqual(response.context_data["filters"], Filters.choices) self.assertEqual(response.context_data["loadmoretopic_url"], loadmoretopic_url) self.assertEqual(response.context_data["forum"], self.forum) - self.assertIsNone(response.context_data["rating"]) self.assertEqual(response.context_data["active_filter_name"], Filters.ALL.label) self.assertEqual(response.context_data["active_tags"], "") @@ -196,7 +195,7 @@ def test_queries(self): TopicFactory.create_batch(20, with_post=True) self.client.force_login(self.user) - with self.assertNumQueries(23): + with self.assertNumQueries(22): self.client.get(self.url) def test_certified_post_display(self): @@ -338,7 +337,7 @@ def test_filtered_queryset_on_tag(self): tag = faker.word() topic = TopicFactory(forum=self.forum, with_tags=[tag], with_post=True) - with self.assertNumQueries(20): + with self.assertNumQueries(19): response = self.client.get( reverse("forum_extension:forum", kwargs={"pk": self.forum.pk, "slug": self.forum.slug}), {"tags": tag} ) @@ -652,7 +651,7 @@ def test_numqueries_on_tags(self, client, db, django_assert_num_queries): 20, parent=category_forum, with_public_perms=True, with_tags=[f"tag{i}" for i in range(3)] ) # vincentporte TOBEFIXED : DUPLICATED QUERIES - with django_assert_num_queries(19): + with django_assert_num_queries(18): client.get(category_forum.get_absolute_url()) diff --git a/lacommunaute/forum/views.py b/lacommunaute/forum/views.py index 10f258b83..306ab8c7e 100644 --- a/lacommunaute/forum/views.py +++ b/lacommunaute/forum/views.py @@ -88,8 +88,6 @@ def get_context_data(self, **kwargs): context["loadmoretopic_suffix"] = "topicsinforum" context["form"] = PostForm(forum=forum, user=self.request.user) - context["rating"] = forum.get_session_rating(self.request.session.session_key) - context["filter_dropdown_endpoint"] = ( None if self.request.GET.get("page")