Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vérifie qu'une alerte n'a pas déjà été résolue avant de la résoudre #6488

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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