New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Creatability of page types incorrectly affecting the can_reorder_subpages()
check
#11944
base: main
Are you sure you want to change the base?
Conversation
…ge types: That mechanism is to prevent manual creation, but it doesn't mean that children aren't editable
Manage this branch in SquashTest this branch here: https://ababicfixcan-reorder-children-80vsi.squash.io |
Thanks, I haven't looked into this but it seems like it would fix #3465 |
…d to check anything on it
e627024
to
b8bb5db
Compare
b8bb5db
to
3e0b24a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ababic!
I was also testing with subpage_types = []
which would now show the "Sort menu order" option as well, even though you cannot actually reorder the children (since the operation would basically still do a "move" to the parent page). However, this is an edge case that doesn't seem worth considering because this only happens if the child pages were created prior to setting the subpage_types = []
. If there's a child page despite the model has subpage_types = []
, that sounds like an unrelated data integrity issue.
That said, could you also add a test case on the reordering view itself, to ensure that this works when the action is performed?
We have a similar test case that relates to the parent_page_types
restriction here:
wagtail/wagtail/admin/tests/pages/test_reorder_page.py
Lines 114 to 142 in 8ddf472
class TestPageReorderWithParentPageRestrictions(TestPageReorder): | |
""" | |
This testCase is the same as the TestPageReorder class above, but with a different | |
page type: BusinessChild has a parent_page_types restriction. | |
This ensures that this restriction doesn't affect the ability to reorder pages. | |
""" | |
def setUp(self): | |
# Find root page | |
self.root_page = Page.objects.get(id=2) | |
# root | |
# |- index_page (BusinessIndex) | |
# | |- child_1 (BusinessChild) | |
# | |- child_2 (BusinessChild) | |
# | |- child_3 (BusinessChild) | |
self.index_page = BusinessIndex(title="Simple", slug="simple") | |
self.root_page.add_child(instance=self.index_page) | |
self.child_1 = BusinessChild(title="Child 1 of BusinessIndex", slug="child-1") | |
self.index_page.add_child(instance=self.child_1) | |
self.child_2 = BusinessChild(title="Child 2 of BusinessIndex", slug="child-2") | |
self.index_page.add_child(instance=self.child_2) | |
self.child_3 = BusinessChild(title="Child 3 of BusinessIndex", slug="child-3") | |
self.index_page.add_child(instance=self.child_3) | |
# Login | |
self.user = self.login() |
Would be nice to have the same for subpage_types
🙂
can_reorder_subpages()
check
Co-authored-by: sage <laymonage@gmail.com>
Fixes #3465
Where all of the page types in
allowed_subpage_types
haveis_creatable=False
on them, it is currently not possible to reorder pages that exist below instances of that page type.I'm classifying this as a bug, because I have always interpreted the
is_creatable=False
mechanism as a way to prevent manual creation ONLY. Not only do I feel it is perfectly valid for programatically-created pages to exist at certain locations (and remain editable/publishable/deletable). But, projects also have a life outside of the current state of the codebase... it's quite possible for pages to have been created before the current code state (whereis_creatable
orallowed_subpage_types
have changed); In which case, the ability to manage those pages (including 'reordering') should not be impacted.