From 324f5b49078ce9448da2058915f97204178f310e Mon Sep 17 00:00:00 2001 From: Arnaud-D <35631001+Arnaud-D@users.noreply.github.com> Date: Fri, 23 Dec 2022 13:24:01 +0100 Subject: [PATCH] Refactorise l'affichage de l'obsolescence * pour utiliser le nouveau vocabulaire * en retirant une duplication de code --- .../tutorialv2/includes/obsolescence_warning.part.html | 9 +++++++++ templates/tutorialv2/view/container_online.html | 8 +------- templates/tutorialv2/view/content_online.html | 8 +------- zds/tutorialv2/tests/tests_views/tests_published.py | 9 +++++---- 4 files changed, 16 insertions(+), 18 deletions(-) create mode 100644 templates/tutorialv2/includes/obsolescence_warning.part.html diff --git a/templates/tutorialv2/includes/obsolescence_warning.part.html b/templates/tutorialv2/includes/obsolescence_warning.part.html new file mode 100644 index 0000000000..97ade1daec --- /dev/null +++ b/templates/tutorialv2/includes/obsolescence_warning.part.html @@ -0,0 +1,9 @@ +{% load i18n %} + +
+
+ {% blocktrans %} + Cette publication est obsolète. Elle peut contenir des informations intéressantes, mais faites preuve de prudence. + {% endblocktrans %} +
+
diff --git a/templates/tutorialv2/view/container_online.html b/templates/tutorialv2/view/container_online.html index ab6ff983eb..688751dfe7 100644 --- a/templates/tutorialv2/view/container_online.html +++ b/templates/tutorialv2/view/container_online.html @@ -59,13 +59,7 @@

{% include 'tutorialv2/includes/tags_authors.part.html' with content=content online=True is_part_or_chapter=True %} {% if is_obsolete %} -
-
- {% blocktrans %} - Ce contenu est obsolète. Il peut contenir des informations intéressantes mais soyez prudent avec celles-ci. - {% endblocktrans %} -
-
+ {% include "tutorialv2/includes/obsolescence_warning.part.html" %} {% endif %} {% endblock %} diff --git a/templates/tutorialv2/view/content_online.html b/templates/tutorialv2/view/content_online.html index a5175aeb6b..eca1686439 100644 --- a/templates/tutorialv2/view/content_online.html +++ b/templates/tutorialv2/view/content_online.html @@ -93,13 +93,7 @@

{% include 'tutorialv2/includes/tags_authors.part.html' with content=content online=True %} {% if is_obsolete %} -
-
- {% blocktrans %} - Ce contenu est obsolète. Il peut contenir des informations intéressantes mais soyez prudent avec celles-ci. - {% endblocktrans %} -
-
+ {% include "tutorialv2/includes/obsolescence_warning.part.html" %} {% endif %} {% endblock %} diff --git a/zds/tutorialv2/tests/tests_views/tests_published.py b/zds/tutorialv2/tests/tests_views/tests_published.py index e8817e7448..fa86bf9e41 100644 --- a/zds/tutorialv2/tests/tests_views/tests_published.py +++ b/zds/tutorialv2/tests/tests_views/tests_published.py @@ -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) @@ -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"""