0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-22 02:18:39 +01:00

Raise 404 with bulk actions for models which don't exist

Fixes #11491
This commit is contained in:
Alex Tomkins 2024-01-12 22:19:00 +00:00 committed by LB (Ben Johnston)
parent 80f433143d
commit f73ae8db90
4 changed files with 18 additions and 1 deletions

View File

@ -76,6 +76,7 @@ Changelog
* Fix: Ensure `MultipleChooserPanel` modal works correctly when `USE_THOUSAND_SEPARATOR` is `True` for pages with ids over 1,000 (Sankalp, Rohit Sharma)
* Fix: When using an empty table header (`th`) for visual spacing, ensure this is ignored by accessibility tooling (V Rohitansh)
* Fix: Ensure the panel anchor button sizes meet accessibility guidelines for minimum dimensions (Nandini Arora)
* Fix: Raise a 404 for bulk actions for models which don't exist instead of throwing a 500 error (Alex Tomkins)
* Docs: Document, for contributors, the use of translate string literals passed as arguments to tags and filters using `_()` within templates (Chiemezuo Akujobi)
* Docs: Document all features for the Documents app in one location (Neeraj Yetheendran)
* Docs: Add section to testing docs about creating pages and working with page content (Mariana Bedran Lesche)

View File

@ -109,6 +109,7 @@ Thank you to Thibaud Colas, Badr Fourane, and Sage Abdullah for their work on th
* Ensure `MultipleChooserPanel` modal works correctly when `USE_THOUSAND_SEPARATOR` is `True` for pages with ids over 1,000 (Sankalp, Rohit Sharma)
* When using an empty table header (`th`) for visual spacing, ensure this is ignored by accessibility tooling (V Rohitansh)
* Ensure the panel anchor button sizes meet accessibility guidelines for minimum dimensions (Nandini Arora)
* Raise a 404 for bulk actions for models which don't exist instead of throwing a 500 error (Alex Tomkins)
### Documentation

View File

@ -20,3 +20,15 @@ class TestBulkActionDispatcher(WagtailTestUtils, TestCase):
)
response = self.client.get(url)
self.assertEqual(response.status_code, 404)
def test_bulk_action_invalid_model(self):
url = reverse(
"wagtail_bulk_action",
args=(
"doesnotexist",
"doesnotexist",
"doesnotexist",
),
)
response = self.client.get(url)
self.assertEqual(response.status_code, 404)

View File

@ -5,7 +5,10 @@ from wagtail.admin.views.bulk_action.registry import bulk_action_registry as reg
def index(request, app_label, model_name, action):
model = apps.get_model(app_label, model_name)
try:
model = apps.get_model(app_label, model_name)
except LookupError:
raise Http404
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)