From cd038ed4f00b80f6f3eb452523ecf78c0c628ee1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Tue, 15 Jan 2019 08:14:16 +0100 Subject: [PATCH] misc: add support for sharing custom 404 page (#29836) --- combo/public/views.py | 6 ++++++ tests/test_public.py | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/combo/public/views.py b/combo/public/views.py index de78a223..99fd1a97 100644 --- a/combo/public/views.py +++ b/combo/public/views.py @@ -214,6 +214,12 @@ def skeleton(request): raise PermissionDenied() source = request.GET['source'] + if source == '404': + request.extra_context_data = {'site_base': request.build_absolute_uri('/')[:-1]} + response = error404(request) + response.status_code = 200 + return response + parsed_source = urlparse.urlparse(source) netloc = parsed_source.netloc if parsed_source.scheme == 'https' and netloc.endswith(':443'): diff --git a/tests/test_public.py b/tests/test_public.py index 2c8d6ae1..bbf09389 100644 --- a/tests/test_public.py +++ b/tests/test_public.py @@ -275,6 +275,11 @@ def test_page_skeleton(app): resp = app.get('/__skeleton__/?source=%s' % quote('http://127.0.0.1:8999/')) assert 'RestrictedVisibility' in resp.text + # check 404 skeleton + resp = app.get('/__skeleton__/?source=404') + assert "This page doesn't exist" in resp.text + assert resp.status_code == 200 + def test_subpage_location(app): Page.objects.all().delete()