data: remove order field from page snapshots (#86627)

This commit is contained in:
Lauréline Guérin 2024-02-13 15:03:27 +01:00
parent 150f6e954f
commit b20230d34f
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
2 changed files with 11 additions and 0 deletions

View File

@ -819,6 +819,8 @@ class PageSnapshot(models.Model):
snapshot.user = request.user
if not deletion:
snapshot.serialization = page.get_serialized_page()
# remove order from serialization
del snapshot.serialization['fields']['order']
else:
snapshot.serialization = {}
snapshot.comment = comment or _('deletion')
@ -849,6 +851,8 @@ class PageSnapshot(models.Model):
return self.load_page(json_page)
def load_page(self, json_page, snapshot=None):
# keep current page order
json_page['fields']['order'] = self.page.order
try:
post_save.disconnect(cell_maintain_page_cell_cache)
post_delete.disconnect(cell_maintain_page_cell_cache)

View File

@ -518,6 +518,13 @@ def test_get_descendants_and_me():
assert [int(x.title) for x in page.get_descendants_and_me()] == [3]
def test_snapshot_page():
page = Page.objects.create(title='One', slug='one', template_name='standard')
PageSnapshot.take(page)
snapshot = PageSnapshot.objects.get()
assert 'order' not in snapshot.serialization['fields']
def test_clear_snapshot_pages():
page = Page.objects.create(title='One', slug='one', template_name='standard')
TextCell.objects.create(page=page, text='foo', order=0, placeholder='content')