diff --git a/zds/tutorialv2/tests/tests_utils.py b/zds/tutorialv2/tests/tests_utils.py index 4e52de2902..c3bcc62e2d 100644 --- a/zds/tutorialv2/tests/tests_utils.py +++ b/zds/tutorialv2/tests/tests_utils.py @@ -556,7 +556,7 @@ def test_no_alert_on_unpublish(self): reaction = ContentReactionFactory( related_content=published, author=ProfileFactory().user, position=1, pubdate=datetime.datetime.now() ) - Alert.objects.create( + alert = Alert.objects.create( scope="CONTENT", comment=reaction, text="a text", @@ -569,6 +569,15 @@ def test_no_alert_on_unpublish(self): unpublish_content(published, staff) self.assertEqual(0, get_header_notifications(staff)["alerts"]["total"]) + # Try to solve the alert anyway (related to #6478): + self.client.force_login(self.staff) + result = self.client.post( + reverse("content:resolve-content", kwargs={"pk": published.pk}), + {"alert_pk": alert.pk, "text": "Anéfé!"}, + follow=False, + ) + self.assertEqual(result.status_code, 404) + def tearDown(self): super().tearDown() PublicatorRegistry.registry = self.old_registry diff --git a/zds/tutorialv2/views/alerts.py b/zds/tutorialv2/views/alerts.py index d120707b1e..880e592bfa 100644 --- a/zds/tutorialv2/views/alerts.py +++ b/zds/tutorialv2/views/alerts.py @@ -62,6 +62,9 @@ def post(self, request, *args, **kwargs): except (KeyError, ValueError): raise Http404("L'alerte n'existe pas.") + if alert.solved: + raise Http404("L'alerte a déjà été résolue.") + resolve_reason = "" msg_title = "" msg_content = ""