Add search link to 404 page
This commit is contained in:
parent
d52d532d81
commit
b620e0edcc
4 changed files with 6 additions and 3 deletions
|
@ -24,7 +24,7 @@
|
||||||
<h1>There's nothing here!</h1>
|
<h1>There's nothing here!</h1>
|
||||||
<p>The page you are looking for could not be found.</p>
|
<p>The page you are looking for could not be found.</p>
|
||||||
<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>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -22,7 +22,7 @@ class Error404PageTestCase(TestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_queries(self) -> None:
|
def test_queries(self) -> None:
|
||||||
with self.assertNumQueries(21):
|
with self.assertNumQueries(22):
|
||||||
self.client.get(self.url)
|
self.client.get(self.url)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,9 @@ from django.views.generic import TemplateView
|
||||||
from wagtail.models import Page
|
from wagtail.models import Page
|
||||||
from wagtail.query import PageQuerySet
|
from wagtail.query import PageQuerySet
|
||||||
|
|
||||||
|
from website.contrib.singleton_page.utils import SingletonPageCache
|
||||||
from website.home.models import HomePage
|
from website.home.models import HomePage
|
||||||
|
from website.search.models import SearchPage
|
||||||
|
|
||||||
from .models import BaseContentPage, BasePage
|
from .models import BaseContentPage, BasePage
|
||||||
|
|
||||||
|
@ -29,6 +31,7 @@ class Error404View(TemplateView):
|
||||||
def get_context_data(self, **kwargs: dict) -> dict:
|
def get_context_data(self, **kwargs: dict) -> dict:
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context["homepage"] = HomePage.objects.get()
|
context["homepage"] = HomePage.objects.get()
|
||||||
|
context["search_url"] = SingletonPageCache.get_url(SearchPage, self.request)
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ class SearchPageResultsTestCase(TestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_too_high_page(self) -> None:
|
def test_too_high_page(self) -> None:
|
||||||
with self.assertNumQueries(46):
|
with self.assertNumQueries(47):
|
||||||
response = self.client.get(
|
response = self.client.get(
|
||||||
self.url, {"q": "post", "page": 3}, HTTP_HX_REQUEST="true"
|
self.url, {"q": "post", "page": 3}, HTTP_HX_REQUEST="true"
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue