fix issue where bulk actions would return, not raise 404

return Http404 -> raise Http404
See #7911
pull/8274/head
Ihor Marhitych 2022-02-02 10:23:26 +01:00 zatwierdzone przez LB Johnston
rodzic 26f85ab7d3
commit 3cd7e967c1
5 zmienionych plików z 41 dodań i 2 usunięć

Wyświetl plik

@ -1,6 +1,12 @@
Changelog
=========
2.15.4 (xx.xx.xxxx) - IN DEVELOPMENT
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Fix issue where invalid bulk action URLs would incorrectly trigger a server error (500) instead of a valid not found (404) (Ihor Marhitych)
2.15.3 (26.01.2022)
~~~~~~~~~~~~~~~~~~~

Wyświetl plik

@ -0,0 +1,16 @@
=============================================
Wagtail 2.15.4 release notes - IN DEVELOPMENT
=============================================
.. contents::
:local:
:depth: 1
What's new
==========
Bug fixes
~~~~~~~~~
* Fix issue where invalid bulk action URLs would incorrectly trigger a server error (500) instead of a valid not found (404) (Ihor Marhitych)

Wyświetl plik

@ -5,6 +5,7 @@ Release notes
:maxdepth: 1
upgrading
2.15.4
2.15.3
2.15.2
2.15.1

Wyświetl plik

@ -0,0 +1,16 @@
from django.test import TestCase
from django.urls import reverse
from wagtail.tests.utils import WagtailTestUtils
class TestBulkActionDispatcher(TestCase, WagtailTestUtils):
def setUp(self):
# Login
self.user = self.login()
def test_bulk_action_invalid_action(self):
url = reverse('wagtail_bulk_action', args=('wagtailcore', 'page', 'ships', ))
response = self.client.get(url)
self.assertEqual(response.status_code, 404)

Wyświetl plik

@ -1,5 +1,5 @@
from django.apps import apps
from django.http.response import Http404
from django.http import Http404
from wagtail.admin.views.bulk_action.registry import bulk_action_registry as registry
@ -9,4 +9,4 @@ def index(request, app_label, model_name, action):
action_class = registry.get_bulk_action_class(app_label, model_name, action)
if action_class is not None:
return action_class(request, model).dispatch(request)
return Http404()
raise Http404