Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limiter l'affichage des questions non répondues aux thématiques publiques #305

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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