Skip to content

Commit

Permalink
feat(forum_conversation): hide unanswered topics from private forums …
Browse files Browse the repository at this point in the history
…in filtered list
  • Loading branch information
vincentporte committed Jun 12, 2023
1 parent 3e13e04 commit 95ce727
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 15 additions & 2 deletions lacommunaute/forum_conversation/tests/tests_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ def setUpTestData(cls):
)

def test_machina_route_forbidden(self):

self.client.force_login(self.poster)

post_data = {"content": "c"}
Expand Down Expand Up @@ -586,7 +585,6 @@ def test_context(self):
self.assertEqual(response.context_data["active_filter_name"], Filters.ALL.label)

def test_has_liked(self):

self.client.force_login(self.user)
response = self.client.get(self.url)
# icon: solid heart
Expand Down Expand Up @@ -655,6 +653,21 @@ def test_queryset(self):
with self.subTest(topic):
self.assertNotContains(response, topic.subject)

def test_unanswerd_topics_visibility(self):
url = self.url + "?filter=NEW"
self.client.force_login(self.user)

response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertContains(response, self.topic.subject)

self.forum.is_private = True
self.forum.save()

response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertNotContains(response, self.topic.subject)

def test_certified_topics_list_content(self):
certified_private_topic = TopicFactory(with_certified_post=True, forum=ForumFactory(is_private=True))
certified_public_topic = TopicFactory(with_certified_post=True, forum=self.forum)
Expand Down
2 changes: 1 addition & 1 deletion lacommunaute/forum_conversation/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def get_queryset(self):
qs = Topic.objects.filter(forum__in=forums).optimized_for_topics_list(self.request.user.id)

if self.get_filter() == Filters.NEW:
qs = qs.unanswered()
qs = qs.unanswered().filter(forum__in=Forum.objects.public())
elif self.get_filter() == Filters.CERTIFIED:
qs = qs.filter(certified_post__isnull=False)

Expand Down

0 comments on commit 95ce727

Please sign in to comment.