data: fix link cell to url import (#61446)
This commit is contained in:
parent
757cd93c76
commit
b64a4e6c08
|
@ -1486,7 +1486,7 @@ class LinkCell(CellBase):
|
|||
|
||||
@classmethod
|
||||
def prepare_serialized_data(cls, cell_data):
|
||||
if 'link_page' in cell_data['fields']:
|
||||
if cell_data['fields'].get('link_page'):
|
||||
link_page_slug = cell_data['fields']['link_page'][0].strip('/').split('/')[-1]
|
||||
if link_page_slug not in cls.get_page_slugs():
|
||||
del cell_data['fields']['link_page']
|
||||
|
|
|
@ -534,3 +534,15 @@ def test_import_export_linkcell_to_missing_page(app, admin_user):
|
|||
cell = LinkCell.objects.get()
|
||||
assert cell.link_page is None
|
||||
assert cell.get_validity_info().invalid_reason_code == 'data_url_not_defined'
|
||||
|
||||
|
||||
def test_import_export_linkcell_to_url(app, admin_user):
|
||||
page1 = Page.objects.create(title='One', slug='one')
|
||||
LinkCell.objects.create(page=page1, url='https://example.com', placeholder='content', order=0)
|
||||
|
||||
output = get_output_of_command('export_site')
|
||||
payload = json.loads(output)
|
||||
import_site(data=payload, clean=True)
|
||||
|
||||
cell = LinkCell.objects.get()
|
||||
assert cell.url == 'https://example.com'
|
||||
|
|
Loading…
Reference in New Issue