From b620e0edcc23264ac100717f0f78990b9457de51 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Fri, 5 May 2023 12:39:39 +0100 Subject: [PATCH] Add search link to 404 page --- website/common/templates/404.html | 2 +- website/common/tests/test_views.py | 2 +- website/common/views.py | 3 +++ website/search/tests.py | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/website/common/templates/404.html b/website/common/templates/404.html index 60ee424..b1e479e 100644 --- a/website/common/templates/404.html +++ b/website/common/templates/404.html @@ -24,7 +24,7 @@

There's nothing here!

The page you are looking for could not be found.

- Go home + Go home or Search for something else.

{% endblock %} diff --git a/website/common/tests/test_views.py b/website/common/tests/test_views.py index 8dfa488..ac3deaf 100644 --- a/website/common/tests/test_views.py +++ b/website/common/tests/test_views.py @@ -22,7 +22,7 @@ class Error404PageTestCase(TestCase): ) def test_queries(self) -> None: - with self.assertNumQueries(21): + with self.assertNumQueries(22): self.client.get(self.url) diff --git a/website/common/views.py b/website/common/views.py index c5f8538..e3269ab 100644 --- a/website/common/views.py +++ b/website/common/views.py @@ -12,7 +12,9 @@ from django.views.generic import TemplateView from wagtail.models import Page from wagtail.query import PageQuerySet +from website.contrib.singleton_page.utils import SingletonPageCache from website.home.models import HomePage +from website.search.models import SearchPage from .models import BaseContentPage, BasePage @@ -29,6 +31,7 @@ class Error404View(TemplateView): def get_context_data(self, **kwargs: dict) -> dict: context = super().get_context_data(**kwargs) context["homepage"] = HomePage.objects.get() + context["search_url"] = SingletonPageCache.get_url(SearchPage, self.request) return context diff --git a/website/search/tests.py b/website/search/tests.py index 2bd554b..01f51fa 100644 --- a/website/search/tests.py +++ b/website/search/tests.py @@ -89,7 +89,7 @@ class SearchPageResultsTestCase(TestCase): ) def test_too_high_page(self) -> None: - with self.assertNumQueries(46): + with self.assertNumQueries(47): response = self.client.get( self.url, {"q": "post", "page": 3}, HTTP_HX_REQUEST="true" )