Skip to content

Commit

Permalink
Refactorise l'affichage de l'obsolescence
Browse files Browse the repository at this point in the history
* pour utiliser le nouveau vocabulaire
* en retirant une duplication de code
  • Loading branch information
Arnaud-D committed Dec 24, 2022
1 parent de1aaa9 commit 324f5b4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
9 changes: 9 additions & 0 deletions templates/tutorialv2/includes/obsolescence_warning.part.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% load i18n %}

<div class="content-wrapper">
<div class="alert-box warning">
{% blocktrans %}
Cette publication est obsolète. Elle peut contenir des informations intéressantes, mais faites preuve de prudence.
{% endblocktrans %}
</div>
</div>
8 changes: 1 addition & 7 deletions templates/tutorialv2/view/container_online.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,7 @@ <h1>
{% include 'tutorialv2/includes/tags_authors.part.html' with content=content online=True is_part_or_chapter=True %}

{% if is_obsolete %}
<div class="content-wrapper">
<div class="alert-box warning">
{% blocktrans %}
Ce contenu est obsolète. Il peut contenir des informations intéressantes mais soyez prudent avec celles-ci.
{% endblocktrans %}
</div>
</div>
{% include "tutorialv2/includes/obsolescence_warning.part.html" %}
{% endif %}
{% endblock %}

Expand Down
8 changes: 1 addition & 7 deletions templates/tutorialv2/view/content_online.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,7 @@ <h2 class="subtitle" itemprop="description">
{% include 'tutorialv2/includes/tags_authors.part.html' with content=content online=True %}

{% if is_obsolete %}
<div class="content-wrapper">
<div class="alert-box warning">
{% blocktrans %}
Ce contenu est obsolète. Il peut contenir des informations intéressantes mais soyez prudent avec celles-ci.
{% endblocktrans %}
</div>
</div>
{% include "tutorialv2/includes/obsolescence_warning.part.html" %}
{% endif %}
{% endblock %}

Expand Down
9 changes: 5 additions & 4 deletions zds/tutorialv2/tests/tests_views/tests_published.py
Original file line number Diff line number Diff line change
Expand Up @@ -1625,6 +1625,7 @@ def test_beta_article_closed_when_published(self):

def test_obsolete(self):
# check that this function is only available for staff
message = _("Cette publication est obsolète.")
self.client.force_login(self.user_author)
result = self.client.post(reverse("validation:mark-obsolete", kwargs={"pk": self.tuto.pk}), follow=False)
self.assertEqual(result.status_code, 403)
Expand All @@ -1633,24 +1634,24 @@ def test_obsolete(self):
# check that when the content is not marked as obsolete, the alert is not shown
result = self.client.get(self.tuto.get_absolute_url_online(), follow=False)
self.assertEqual(result.status_code, 200)
self.assertNotContains(result, _("Ce contenu est obsolète."))
self.assertNotContains(result, message)
# now, let's mark the tutoriel as obsolete
result = self.client.post(reverse("validation:mark-obsolete", kwargs={"pk": self.tuto.pk}), follow=False)
self.assertEqual(result.status_code, 302)
# check that the alert is shown
result = self.client.get(self.tuto.get_absolute_url_online(), follow=False)
self.assertEqual(result.status_code, 200)
self.assertContains(result, _("Ce contenu est obsolète."))
self.assertContains(result, message)
# and on a chapter
result = self.client.get(self.chapter1.get_absolute_url_online(), follow=False)
self.assertEqual(result.status_code, 200)
self.assertContains(result, _("Ce contenu est obsolète."))
self.assertContains(result, message)
# finally, check that this alert can be hidden
result = self.client.post(reverse("validation:mark-obsolete", kwargs={"pk": self.tuto.pk}), follow=False)
self.assertEqual(result.status_code, 302)
result = self.client.get(self.tuto.get_absolute_url_online(), follow=False)
self.assertEqual(result.status_code, 200)
self.assertNotContains(result, _("Ce contenu est obsolète."))
self.assertNotContains(result, message)

def test_list_publications(self):
"""Test the behavior of the publication list"""
Expand Down

0 comments on commit 324f5b4

Please sign in to comment.