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

Fix #5022: les messages masqués ne sont plus considérés comme utiles #5023

Merged
merged 1 commit into from Aug 24, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions templates/misc/message.part.html
Expand Up @@ -19,7 +19,7 @@
<article
class="topic-message

{% if message.is_useful %}helpful{% endif %}
{% if message.is_useful and message.is_visible %}helpful{% endif %}
{% if is_repeated_message %}repeated{% endif %}"

{% if comment_schema %}
Expand Down Expand Up @@ -173,7 +173,7 @@
{% trans "Reprise du dernier message de la page précédente" %}
</p>
{% endif %}
<p class="message-helpful tick ico-after green {% if not message.is_useful or is_creator %}hidden{% endif %}"
<p class="message-helpful tick ico-after green {% if not message.is_useful or not message.is_visible %}hidden{% endif %}"
data-ajax-output="mark-message-as-useful">
{% trans "Cette réponse a aidé l’auteur du sujet" %}
</p>
Expand Down
19 changes: 19 additions & 0 deletions zds/forum/tests/tests_views.py
Expand Up @@ -1412,6 +1412,25 @@ def test_success_edit_post_hide_message_by_staff(self):
self.assertEqual(staff.user, post.editor)
self.assertEqual(text_hidden_expected, post.text_hidden)

def test_hide_helpful_message(self):
profile = ProfileFactory()
category, forum = create_category()
topic = add_topic_in_a_forum(forum, profile)

self.assertTrue(self.client.login(username=profile.user.username, password='hostel77'))
response = self.client.post(reverse('post-useful') + '?message={}'.format(topic.last_message.pk), follow=False)
self.assertEqual(302, response.status_code)

response = self.client.get(topic.get_absolute_url(), follow=False)
self.assertNotContains(response, 'green hidden')

response = self.client.post(
reverse('post-edit') + '?message={}'.format(topic.last_message.pk), {'delete_message': ''}, follow=False)
self.assertEqual(302, response.status_code)

response = self.client.get(topic.get_absolute_url(), follow=False)
self.assertContains(response, 'green hidden')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tu pourrais aussi ajouter un notContains("helpful")?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

En fait non (c'était ma première intention), car il y a helpful-message dans le code, que le message soit utile ou non.


def test_failure_edit_post_show_message_by_user(self):
another_profile = ProfileFactory()
category, forum = create_category()
Expand Down