misc: include cells from homepage in error 404 page (#43851)

This commit is contained in:
Frédéric Péters 2020-06-10 10:52:47 +02:00
parent f36306ceea
commit 5d75e92845
2 changed files with 12 additions and 1 deletions

View File

@ -583,7 +583,7 @@ def error404(request, *args, **kwargs):
page = Page.objects.get(slug='404')
template_name = None
except Page.DoesNotExist:
page = Page()
page = Page.objects.filter(slug='index', parent=None).first() or Page()
page.template_name = 'standard'
template_name = 'combo/404.html'
return publish_page(request, page, status=404, template_name=template_name)

View File

@ -499,6 +499,17 @@ def test_404(app):
resp = app.get('/foobar/', status=404)
assert "This page doesn't exist" in resp.text
# check footer cells are taken from homepage
index_page = Page(title='Home', slug='index', template_name='standard')
index_page.save()
cell = TextCell(page=index_page, placeholder='footer', text='FOOBAR', order=0)
cell.save()
resp = app.get('/foobar/', status=404)
assert "This page doesn't exist" in resp.text
assert "FOOBAR" in resp.text
index_page.delete()
# check decidated custom page
page = Page(title='Not Found', slug='404', template_name='standard')
page.save()
TextCell(page=page, placeholder='content', text='Custom 404 Text', order=0).save()