From c174520f949379d5aa6b911cdc8b932c0ce78808 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 28 Apr 2026 12:09:08 +0000 Subject: [PATCH 1/2] Initial plan From 8591ac82f4694a56a313f5b7f7c68afa981b872a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 28 Apr 2026 12:26:59 +0000 Subject: [PATCH 2/2] Preserve tree order for subpages in Wagtail admin Agent-Logs-Url: https://github.com/scieloorg/core/sessions/60245919-af45-4a20-8038-2df89fa97dfe Co-authored-by: robertatakenaka <505143+robertatakenaka@users.noreply.github.com> --- core/home/models.py | 13 +++++++++++++ core/home/tests.py | 20 ++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/core/home/models.py b/core/home/models.py index 7befa852..0bbadd03 100755 --- a/core/home/models.py +++ b/core/home/models.py @@ -170,6 +170,12 @@ class HomePage(Page): "home.ListPageJournalByCategory", ] + # Show child pages in their tree (manual) order in the Wagtail admin + # listing, instead of by latest revision date. This keeps the order + # stable when an editor edits a subpage and matches what is shown on + # the public-facing site (which uses `get_children`, ordered by path). + admin_default_ordering = "ord" + content_panels = Page.content_panels + [ InlinePanel("sponsors", label=_("Footer Sponsors"), heading=_("Patrocinadores do Footer")), ] @@ -352,6 +358,13 @@ class Meta: class AboutScieloOrgPage(Page): subpage_types = ["home.AboutScieloOrgPage"] + # Preserve the manual (tree) order of subpages in the Wagtail admin + # listing. Without this, Wagtail's default ``-latest_revision_created_at`` + # ordering causes the most recently edited subpage to jump to the top + # of the list, breaking the predefined order (see issue: "Edição de + # páginas causa reordenamento dos itens"). + admin_default_ordering = "ord" + body = RichTextField(_("Body"), blank=True) external_link = models.URLField( _("Link externo"), blank=True, null=True, max_length=2000 diff --git a/core/home/tests.py b/core/home/tests.py index 19b77133..5174c90f 100644 --- a/core/home/tests.py +++ b/core/home/tests.py @@ -6,9 +6,29 @@ from core.users.models import User from journal.models import Journal, SciELOJournal +from core.home.models import AboutScieloOrgPage, HomePage from core.home.views import _get_scielo_journals_data +class TestSubpageAdminDefaultOrdering(TestCase): + """Regression tests for issue: + "Edição de páginas causa reordenamento dos itens". + + Wagtail's default ``admin_default_ordering`` of + ``-latest_revision_created_at`` would cause a recently edited subpage + to jump to the top of the children listing in the admin, breaking + the predefined order. The fix sets ``admin_default_ordering = "ord"`` + on the relevant page models so that children are always listed in + their tree (manual) order, matching the public-facing site. + """ + + def test_about_scielo_org_page_uses_tree_ordering_in_admin(self): + self.assertEqual(AboutScieloOrgPage.admin_default_ordering, "ord") + + def test_home_page_uses_tree_ordering_in_admin(self): + self.assertEqual(HomePage.admin_default_ordering, "ord") + + class TestGetScieloJournalsData(TestCase): def setUp(self): self.user = User.objects.create(username="testuser", password="testpass")