Skip to content

Commit

Permalink
Don't select the root page as the default destination for MoveBulkAction
Browse files Browse the repository at this point in the history
The test covers a crash (wagtail#10473), which has also been fixed by wagtail#10362.
  • Loading branch information
th3hamm0r committed Feb 19, 2024
1 parent 46cb06a commit 9163ed1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
31 changes: 31 additions & 0 deletions wagtail/admin/tests/pages/test_bulk_actions/test_bulk_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,34 @@ def hook_func(request, action_type, pages, action_class_instance):
Page.objects.get(id=self.test_page_b_1.id).get_parent().id,
self.section_b.id,
)

def test_bulk_move_with_restricted_parent_page_types(self):
board_meetings = Page.objects.get(
url_path="/home/events/businessy-events/board-meetings/"
)
url = (
reverse(
"wagtail_bulk_action",
args=(
"wagtailcore",
"page",
"move",
),
)
+ f"?id={board_meetings.id}"
)
response = self.client.get(url)
self.assertEqual(response.status_code, 200)

html = response.content.decode()

self.assertInHTML("<p>Are you sure you want to move these pages?</p>", html)

self.assertInHTML(
'<li><a href="{edit_page_url}" target="_blank" rel="noreferrer">Board meetings</a></li>'.format(
edit_page_url=reverse(
"wagtailadmin_pages:edit", args=[board_meetings.id]
),
),
html,
)
2 changes: 1 addition & 1 deletion wagtail/admin/views/pages/bulk_actions/move.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self, request, model):

def get_form_kwargs(self):
ctx = super().get_form_kwargs()
ctx["destination"] = self.destination or Page.get_first_root_node()
ctx["destination"] = self.destination
ctx["target_parent_models"] = self.target_parent_models
ctx["pages_to_move"] = self.pages_to_move
return ctx
Expand Down

0 comments on commit 9163ed1

Please sign in to comment.