Skip to content

Commit

Permalink
Vérifie qu'une alerte n'a pas déjà été résolue avant de la résoudre (z…
Browse files Browse the repository at this point in the history
  • Loading branch information
philippemilink committed May 8, 2023
1 parent 21383c7 commit 21413cc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 10 additions & 1 deletion zds/tutorialv2/tests/tests_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions zds/tutorialv2/views/alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand Down

0 comments on commit 21413cc

Please sign in to comment.