Conversation
Agent-Logs-Url: https://github.com/scieloorg/core/sessions/60245919-af45-4a20-8038-2df89fa97dfe Co-authored-by: robertatakenaka <505143+robertatakenaka@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes unintended reordering of AboutScieloOrgPage subpages in the Wagtail admin after edits by overriding Wagtail’s default admin ordering (latest revision timestamp) to use tree order ("ord"), aligning admin behavior with the public site’s path-based ordering.
Changes:
- Set
admin_default_ordering = "ord"onHomePageandAboutScieloOrgPageto keep child listings stable in the Wagtail admin. - Add regression tests asserting the ordering configuration on the relevant page models.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| core/home/models.py | Sets admin_default_ordering = "ord" on the relevant page types to preserve tree/path order in admin listings. |
| core/home/tests.py | Adds regression tests for the new admin_default_ordering configuration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 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 | ||
|
|
||
|
|
There was a problem hiding this comment.
The import grouping/order here looks like it will be reformatted by isort (CI runs pre-commit with isort). Consider running isort or reorganizing imports so local-app imports (collection/journal/core.*) are in a single section and sorted consistently, rather than splitting core.home.* into a separate block.
| 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 | |
| from core.home.models import AboutScieloOrgPage, HomePage | |
| from core.home.views import _get_scielo_journals_data | |
| from core.users.models import User | |
| from journal.models import Journal, SciELOJournal |
| from core.home.views import _get_scielo_journals_data | ||
|
|
||
|
|
||
| class TestSubpageAdminDefaultOrdering(TestCase): |
There was a problem hiding this comment.
This test class only asserts model class attributes and doesn’t use the database; using django.test.SimpleTestCase instead of TestCase would avoid unnecessary DB setup and speed the suite (you’d also need to adjust the import at the top accordingly).
| 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") |
There was a problem hiding this comment.
These tests verify that admin_default_ordering is set, but they don’t actually exercise the regression scenario described in the PR (a subpage moving to the top of the Wagtail admin children listing after edit/publish). Consider adding an integration-style assertion that creates sibling pages, simulates an edit/publish to update latest_revision_created_at, and verifies the admin listing order remains tree/path-based.
O que esse PR faz?
Corrige o reordenamento das subpáginas de
AboutScieloOrgPage(ex.: Sobre o SciELO) toda vez que uma delas era editada — a página recém-editada subia para o topo da listagem no admin do Wagtail, quebrando a ordem pré-definida pelos editores.A causa raiz é o default do Wagtail
Page.admin_default_ordering = "-latest_revision_created_at", que ordena os filhos no admin pelo timestamp da última revisão.admin_default_ordering = "ord"emHomePageeAboutScieloOrgPage, fazendo o admin listar os filhos em ordem de árvore (path), igual ao que o site público já exibe viaget_children.core/home/tests.py.Onde a revisão poderia começar?
core/home/models.py— atributoadmin_default_orderingemHomePageeAboutScieloOrgPage.Como este poderia ser testado manualmente?
AboutScieloOrgPage(ex.: Rede SciELO)./pt-br/sobre-o-scielo/rede-scielo/) continua exibindo a mesma ordem.Algum cenário de contexto que queira dar?
O comando
import_aboutcria as subpáginas em ordem (menu_order) usandoparent.add_child(...), o que define opathcorretamente. O front-end usapage.get_children.live.public, que herda a ordenação porpathdoBasePageManager. O único ponto que ordenava por data de edição era a listagem do admin, que é onde os editores percebiam o problema.Screenshots
N/A — mudança de ordenação no admin; não há alterações visuais no front-end.
Referências
Page.admin_default_orderingwagtail/models/pages.py:421(default-latest_revision_created_at)wagtail/admin/views/pages/listing.py:426(suporte ao valor"ord")Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
www.scielo.org/home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js(dns block)If you need me to access, download, or install something from one of these locations, you can either: