Add search link to 404 page

This commit is contained in:
Jake Howard 2023-05-05 12:39:39 +01:00
parent d52d532d81
commit b620e0edcc
Signed by: jake
GPG key ID: 57AFB45680EDD477
4 changed files with 6 additions and 3 deletions

View file

@ -24,7 +24,7 @@
<h1>There's nothing here!</h1>
<p>The page you are looking for could not be found.</p>
<p>
<a href="{% pageurl homepage %}">Go home</a>
<a href="{% pageurl homepage %}">Go home</a> or <a href="{{ search_url }}">Search for something else</a>.
</p>
</div>
{% endblock %}

View file

@ -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)

View file

@ -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

View file

@ -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"
)