diff --git a/CHANGELOG.txt b/CHANGELOG.txt index d46497d925..8b64a875c5 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -65,6 +65,7 @@ * Fix: Make sure the label of panel collapse buttons is translatable (Thibaud Colas) * Fix: Ensure there is suitable padding for large numbers on pagination within universal listings (M. Sumair Khokhar) * Fix: Use the correct localized format utils in the `human_readable_date` template tag (Seb Corbin) + * Fix: Ensure the editing of translation alias pages correctly shows links to the source page if the alias was created from a draft (Dan Braghis) * Docs: Add missing tag library imports to footer template code in tutorial (Dimaco) * Docs: Improve documentation around securing user-uploaded files (Jake Howard) * Docs: Introduce search_fields in a dedicated tutorial section instead of the introduction (Matt Westcott) diff --git a/docs/releases/7.1.md b/docs/releases/7.1.md index 88146255aa..fcbb7c014f 100644 --- a/docs/releases/7.1.md +++ b/docs/releases/7.1.md @@ -109,6 +109,7 @@ For more details, see the documentation on [enabling the user bar](headless_user * Make sure the label of panel collapse buttons is translatable (Thibaud Colas) * Ensure there is suitable padding for large numbers on pagination within universal listings (M. Sumair Khokhar) * Use the correct localized format utils in the `human_readable_date` template tag (Seb Corbin) + * Ensure the editing of translation alias pages correctly shows links to the source page if the alias was created from a draft (Dan Braghis) ### Documentation diff --git a/wagtail/actions/create_alias.py b/wagtail/actions/create_alias.py index ae942e3361..c1ff37e83a 100644 --- a/wagtail/actions/create_alias.py +++ b/wagtail/actions/create_alias.py @@ -120,6 +120,7 @@ class CreatePageAliasAction: "path", "index_entries", "postgres_index_entries", + "latest_revision", # for page aliases do not have revisions ] update_attrs = { diff --git a/wagtail/admin/tests/pages/test_edit_page.py b/wagtail/admin/tests/pages/test_edit_page.py index b13e11306f..63bf9c72e2 100644 --- a/wagtail/admin/tests/pages/test_edit_page.py +++ b/wagtail/admin/tests/pages/test_edit_page.py @@ -2139,6 +2139,31 @@ class TestPageEdit(WagtailTestUtils, TestCase): html=True, ) + def test_edit_alias_page_from_draft_page(self): + # Ensure we have at least one revision. This is what happens when creating + # a page via the admin. It is stored as latest_revision + self.unpublished_page.save_revision() + alias_page = self.unpublished_page.create_alias(update_slug="an-alias-page") + response = self.client.get( + reverse("wagtailadmin_pages:edit", args=[alias_page.id]) + ) + + self.assertEqual(response.status_code, 200) + self.assertEqual(response["Content-Type"], "text/html; charset=utf-8") + + self.assertNotContains(response, 'id="status-sidebar-live"') + + # Check the edit_alias.html template was used instead + self.assertTemplateUsed(response, "wagtailadmin/pages/edit_alias.html") + original_page_edit_url = reverse( + "wagtailadmin_pages:edit", args=[self.unpublished_page.id] + ) + self.assertContains( + response, + f'Edit original page', + html=True, + ) + def test_post_edit_alias_page(self): alias_page = self.child_page.create_alias(update_slug="new-child-page")