From 5d75e9284519511387d6d10397eac99d67be0b9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Wed, 10 Jun 2020 10:52:47 +0200 Subject: [PATCH] misc: include cells from homepage in error 404 page (#43851) --- combo/public/views.py | 2 +- tests/test_public.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/combo/public/views.py b/combo/public/views.py index 124e722a..bc12613b 100644 --- a/combo/public/views.py +++ b/combo/public/views.py @@ -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) diff --git a/tests/test_public.py b/tests/test_public.py index c3cb5c25..48ae78ca 100644 --- a/tests/test_public.py +++ b/tests/test_public.py @@ -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()