call save when deserializing cells (#15673)

This commit is contained in:
Emmanuel Cazenave 2018-05-14 17:17:26 +02:00
parent 4681781bc1
commit 594f5c0e3f
2 changed files with 20 additions and 0 deletions

View File

@ -340,6 +340,8 @@ class Page(models.Model):
# load new cells
for cell in serializers.deserialize('json', json.dumps(cells)):
cell.save()
# will populate cached_* attributes
cell.object.save()
@classmethod
def load_serialized_pages(cls, json_site):

View File

@ -258,6 +258,24 @@ def test_form_cell_save_cache():
'url': 'http://127.0.0.1:8999/form-title/',
'text': ''}]
@wcsctl_present
def test_form_cell_load():
page = Page(title='xxx', slug='test_form_cell_save_cache', template_name='standard')
page.save()
cell = WcsFormCell(page=page, placeholder='content', order=0)
cell.formdef_reference = u'default:form-title'
cell.save()
site_export = [page.get_serialized_page()]
cell.delete()
assert not page.get_cells()
Page.load_serialized_pages(site_export)
cells = page.get_cells()
assert len(cells) == 1
cell = cells[0]
assert cell.cached_title == 'form title'
@wcsctl_present
def test_category_cell_save_cache():
page = Page(title='xxx', slug='test_category_cell_save_cache', template_name='standard')