diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 4bbbd9aee..bab8c8543 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -6,6 +6,7 @@ Changelog * Persist tab hash in URL to allow direct navigation to tabs in the admin interface (Ben Weatherman) * Animate the chevron icon when opening sub-menus in the admin (Carlo Ascani) + * Look through the target link and target page slug (in addition to the old slug) when searching for redirects in the admin (Michael Harrison) * Fix: Status button on 'edit page' now links to the correct URL when live and draft slug differ (LB (Ben Johnston)) * Fix: Image title text in the gallery and in the chooser now wraps for long filenames (LB (Ben Johnston), Luiz Boaretto) * Fix: Move image editor action buttons to the bottom of the form on mobile (Julian Gallo) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index f54b9e4c4..c6b201090 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -277,6 +277,7 @@ Contributors * Carlo Ascani * Julian Gallo * Dan Dietz +* Michael Harrison Translators =========== diff --git a/docs/releases/2.1.rst b/docs/releases/2.1.rst index 4936c5cf7..8a8e05175 100644 --- a/docs/releases/2.1.rst +++ b/docs/releases/2.1.rst @@ -16,6 +16,7 @@ Other features * Persist tab hash in URL to allow direct navigation to tabs in the admin interface (Ben Weatherman) * Animate the chevron icon when opening sub-menus in the admin (Carlo Ascani) +* Look through the target link and target page slug (in addition to the old slug) when searching for redirects in the admin (Michael Harrison) Bug fixes ~~~~~~~~~ diff --git a/wagtail/contrib/redirects/tests.py b/wagtail/contrib/redirects/tests.py index 8b3d8f34a..15b643490 100644 --- a/wagtail/contrib/redirects/tests.py +++ b/wagtail/contrib/redirects/tests.py @@ -291,6 +291,12 @@ class TestRedirectsIndexView(TestCase, WagtailTestUtils): self.assertEqual(response.status_code, 200) self.assertEqual(response.context['query_string'], "Hello") + def test_search_results(self): + models.Redirect.objects.create(old_path="/aaargh", redirect_link="http://torchbox.com/") + models.Redirect.objects.create(old_path="/torchbox", redirect_link="http://aaargh.com/") + response = self.get({'q': "aaargh"}) + self.assertEqual(len(response.context['redirects']), 2) + def test_pagination(self): pages = ['0', '1', '-1', '9999', 'Not a page'] for page in pages: diff --git a/wagtail/contrib/redirects/views.py b/wagtail/contrib/redirects/views.py index c75850d43..c5ac6d871 100644 --- a/wagtail/contrib/redirects/views.py +++ b/wagtail/contrib/redirects/views.py @@ -1,3 +1,4 @@ +from django.db.models import Q from django.shortcuts import get_object_or_404, redirect, render from django.urls import reverse from django.utils.translation import ugettext as _ @@ -24,7 +25,9 @@ def index(request): # Search if query_string: - redirects = redirects.filter(old_path__icontains=query_string) + redirects = redirects.filter(Q(old_path__icontains=query_string) | + Q(redirect_page__url_path__icontains=query_string) | + Q(redirect_link__icontains=query_string)) # Ordering (A bit useless at the moment as only 'old_path' is allowed) if ordering not in ['old_path']: