misc: fix error404 view when raised by combo (#42067)

This commit is contained in:
Lauréline Guérin 2020-04-24 11:13:41 +02:00 committed by Frédéric Péters
parent 33814b5574
commit 67a6caaf70
2 changed files with 9 additions and 1 deletions

View File

@ -239,7 +239,7 @@ def skeleton(request):
if source == '404':
request.extra_context_data = {'site_base': request.build_absolute_uri('/')[:-1]}
response = error404(request)
response = error404(request, exception=Http404())
response.status_code = 200
return response
@ -557,6 +557,7 @@ def publish_page(request, page, status=200, template_name=None):
return render(request, template_name, ctx, status=status)
def error404(request, *args, **kwargs):
if not hasattr(request, 'user'):
# this happens when the 404 handler is called early on, for example
@ -577,6 +578,7 @@ def error404(request, *args, **kwargs):
template_name = 'combo/404.html'
return publish_page(request, page, status=404, template_name=template_name)
def mellon_page_hook(context):
page = Page()
page.title = 'Hello'

View File

@ -516,6 +516,12 @@ def test_404(app):
assert 'Custom 404 Text' not in resp.text
assert "This page doesn't exist" not in resp.text
# check 404 skeleton when all pages are private
resp = app.get('/__skeleton__/?source=404')
assert 'Custom 404 Text' not in resp.text
assert "This page doesn't exist" not in resp.text
assert resp.status_code == 200
def test_style_demo(app, admin_user):
TextCell.objects.all().delete()