Fixes #5807. If the page instance being previewed gets saved (no confirmation that Wagtail itself is doing this, but it could easily happen as a result of some misplaced logic in get_context
or similar), it will block further page creations in a way that's difficult to recover from.
Showing 1 of 1 files from the diff.
@@ -113,9 +113,15 @@
Loading
113 | 113 | # hopefully enable tree traversal operations |
|
114 | 114 | # to at least partially work. |
|
115 | 115 | page.depth = parent_page.depth + 1 |
|
116 | - | # Puts the page at the maximum possible path |
|
116 | + | # Puts the page at the next available path |
|
117 | 117 | # for a child of `parent_page`. |
|
118 | - | page.path = Page._get_children_path_interval(parent_page.path)[1] |
|
118 | + | if parent_page.is_leaf(): |
|
119 | + | # set the path as the first child of parent_page |
|
120 | + | page.path = page._get_path(parent_page.path, page.depth, 1) |
|
121 | + | else: |
|
122 | + | # add the new page after the last child of parent_page |
|
123 | + | page.path = parent_page.get_last_child()._inc_path() |
|
124 | + | ||
119 | 125 | return page |
|
120 | 126 | ||
121 | 127 | def get_form(self, page, query_dict): |
Files | Coverage |
---|---|
client/src | 92.85% |
wagtail | 89.96% |
Project Totals (427 files) | 90.05% |
15374.6
TRAVIS_PYTHON_VERSION=3.8 TRAVIS_OS_NAME=linux TOXENV=py38-dj30-postgres-noelasticsearch
backend
15374.7
TRAVIS_PYTHON_VERSION=3.8 TRAVIS_OS_NAME=linux TOXENV=py38-dj31-postgres-noelasticsearch
backend
15374.9
TRAVIS_PYTHON_VERSION=3.8 TRAVIS_OS_NAME=linux TOXENV=py38-dj31-postgres-noelasticsearch-notz
backend
15374.8
TRAVIS_PYTHON_VERSION=3.8 TRAVIS_OS_NAME=linux TOXENV=py38-dj31-postgres-noelasticsearch-emailuser
backend
15374.3
TRAVIS_PYTHON_VERSION=3.7 TRAVIS_OS_NAME=linux TOXENV=py37-dj22-sqlite-noelasticsearch
backend
15374.5
TRAVIS_PYTHON_VERSION=3.7 TRAVIS_OS_NAME=linux TOXENV=py37-dj30-mysql-noelasticsearch
backend
15374.2
TRAVIS_PYTHON_VERSION=3.6 TRAVIS_OS_NAME=linux TOXENV=py36-dj22-postgres-noelasticsearch
backend
15374.1
TRAVIS_PYTHON_VERSION=3.6 TRAVIS_OS_NAME=linux TOXENV=py36-dj22-mysql-noelasticsearch
backend
15374.10
TRAVIS_PYTHON_VERSION=3.8 TRAVIS_OS_NAME=linux TOXENV=py38-dj31stable-postgres-noelasticsearch
backend
15374.12
TRAVIS_PYTHON_VERSION=3.6 TRAVIS_OS_NAME=linux TOXENV=py36-dj22-sqlite-elasticsearch2
backend
15370.3
TRAVIS_PYTHON_VERSION=3.7 TRAVIS_OS_NAME=linux TOXENV=py37-dj22-sqlite-noelasticsearch
backend
15370.2
TRAVIS_PYTHON_VERSION=3.6 TRAVIS_OS_NAME=linux TOXENV=py36-dj22-postgres-noelasticsearch
backend
15370.4
TRAVIS_PYTHON_VERSION=3.7 TRAVIS_OS_NAME=linux TOXENV=py37-dj30-sqlite-noelasticsearch
backend
15370.5
TRAVIS_PYTHON_VERSION=3.7 TRAVIS_OS_NAME=linux TOXENV=py37-dj30-mysql-noelasticsearch
backend
15370.1
TRAVIS_PYTHON_VERSION=3.6 TRAVIS_OS_NAME=linux TOXENV=py36-dj22-mysql-noelasticsearch
backend
15370.8
TRAVIS_PYTHON_VERSION=3.8 TRAVIS_OS_NAME=linux TOXENV=py38-dj31-postgres-noelasticsearch-emailuser
backend
15370.6
TRAVIS_PYTHON_VERSION=3.8 TRAVIS_OS_NAME=linux TOXENV=py38-dj30-postgres-noelasticsearch
backend
15370.12
TRAVIS_PYTHON_VERSION=3.6 TRAVIS_OS_NAME=linux TOXENV=py36-dj22-sqlite-elasticsearch2
backend
15370.9
TRAVIS_PYTHON_VERSION=3.8 TRAVIS_OS_NAME=linux TOXENV=py38-dj31-postgres-noelasticsearch-notz
backend
15370.10
TRAVIS_PYTHON_VERSION=3.8 TRAVIS_OS_NAME=linux TOXENV=py38-dj31stable-postgres-noelasticsearch
backend