kopia lustrzana https://github.com/wagtail/wagtail
Fix crash when copying an alias page
rodzic
8b71a13f0a
commit
2581a2bc6d
|
@ -1994,14 +1994,17 @@ class Page(AbstractPage, index.Indexed, ClusterableModel, metaclass=PageBase):
|
|||
exclude_fields = self.default_exclude_fields_in_copy + self.exclude_fields_in_copy + (exclude_fields or [])
|
||||
specific_self = self.specific
|
||||
if keep_live:
|
||||
base_update_attrs = {}
|
||||
base_update_attrs = {
|
||||
'alias_of': None,
|
||||
}
|
||||
else:
|
||||
base_update_attrs = {
|
||||
'live': False,
|
||||
'has_unpublished_changes': True,
|
||||
'live_revision': None,
|
||||
'first_published_at': None,
|
||||
'last_published_at': None
|
||||
'last_published_at': None,
|
||||
'alias_of': None,
|
||||
}
|
||||
|
||||
if user:
|
||||
|
|
|
@ -1576,6 +1576,22 @@ class TestCopyPage(TestCase):
|
|||
)
|
||||
self.assertFalse(signal_fired)
|
||||
|
||||
def test_copy_alias_page(self):
|
||||
about_us = SimplePage.objects.get(url_path='/home/about-us/')
|
||||
about_us_alias = about_us.create_alias(update_slug='about-us-alias')
|
||||
|
||||
about_us_alias_copy = about_us_alias.copy(update_attrs={
|
||||
'slug': 'about-us-alias-copy'
|
||||
})
|
||||
|
||||
self.assertIsInstance(about_us_alias_copy, SimplePage)
|
||||
self.assertEqual(about_us_alias_copy.slug, 'about-us-alias-copy')
|
||||
self.assertNotEqual(about_us_alias_copy.id, about_us.id)
|
||||
self.assertEqual(about_us_alias_copy.url_path, '/home/about-us-alias-copy/')
|
||||
|
||||
# The copy should just be a copy of the original page, not an alias
|
||||
self.assertIsNone(about_us_alias_copy.alias_of)
|
||||
|
||||
|
||||
class TestCreateAlias(TestCase):
|
||||
fixtures = ['test.json']
|
||||
|
|
Ładowanie…
Reference in New Issue