From f9104e79274f5d5c9adbba34e0e953b9ea813b01 Mon Sep 17 00:00:00 2001 From: Philippe MILINK Date: Sun, 9 Apr 2023 18:44:36 +0200 Subject: [PATCH] =?UTF-8?q?V=C3=A9rifie=20qu'une=20alerte=20n'a=20pas=20d?= =?UTF-8?q?=C3=A9j=C3=A0=20=C3=A9t=C3=A9=20r=C3=A9solue=20avant=20de=20la?= =?UTF-8?q?=20r=C3=A9soudre?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix #6478 --- zds/tutorialv2/tests/tests_utils.py | 11 ++++++++++- zds/tutorialv2/views/alerts.py | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) 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 = ""