Prevent Draftail from crashing on links to missing pages

pull/4795/merge
Matt Westcott 2018-10-05 12:24:31 +01:00 zatwierdzone przez Thibaud Colas
rodzic 6c7065ef99
commit 2f96465150
2 zmienionych plików z 9 dodań i 2 usunięć

Wyświetl plik

@ -206,7 +206,12 @@ class PageLinkElementHandler(LinkElementHandler):
try:
page = Page.objects.get(id=attrs['id']).specific
except Page.DoesNotExist:
return {}
# retain ID so that it's still identified as a page link (albeit a broken one)
return {
'id': int(attrs['id']),
'url': None,
'parentId': None
}
parent_page = page.get_parent()

Wyświetl plik

@ -326,7 +326,9 @@ class TestHtmlToContentState(TestCase):
'entityMap': {
'0': {
'mutability': 'MUTABLE', 'type': 'LINK',
'data': {}
'data': {
'id': 9999, 'url': None, 'parentId': None,
}
}
},
'blocks': [