kopia lustrzana https://github.com/wagtail/wagtail
Fixed an issue with copying unsaved Pages (#6420)
rodzic
e508cbc9c9
commit
7022d0e37a
|
@ -1756,6 +1756,10 @@ class Page(AbstractPage, index.Indexed, ClusterableModel, metaclass=PageBase):
|
|||
:param log_action flag for logging the action. Pass None to skip logging.
|
||||
Can be passed an action string. Defaults to 'wagtail.copy'
|
||||
"""
|
||||
|
||||
if self._state.adding:
|
||||
raise RuntimeError('Page.copy() called on an unsaved page')
|
||||
|
||||
exclude_fields = self.default_exclude_fields_in_copy + self.exclude_fields_in_copy + (exclude_fields or [])
|
||||
specific_self = self.specific
|
||||
if keep_live:
|
||||
|
|
|
@ -1484,6 +1484,12 @@ class TestCopyPage(TestCase):
|
|||
# reset excluded fields for future tests
|
||||
EventPage.exclude_fields_in_copy = []
|
||||
|
||||
def test_copy_unsaved_page(self):
|
||||
"""Test that unsaved page will not be copied."""
|
||||
new_page = SimplePage(slug='testpurp', title='testpurpose')
|
||||
with self.assertRaises(RuntimeError):
|
||||
new_page.copy()
|
||||
|
||||
|
||||
class TestCopyForTranslation(TestCase):
|
||||
fixtures = ['test.json']
|
||||
|
|
Ładowanie…
Reference in New Issue