Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
mpicms/patches/documents-and-images-support-partial-matches.patch
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
75 lines (65 sloc)
3.33 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From dffa61c525b20f4c0f28e2cd6c045abb31c424f4 Mon Sep 17 00:00:00 2001 | |
From: Donald Buczek <buczek@molgen.mpg.de> | |
Date: Thu, 2 Jan 2020 15:23:36 +0100 | |
Subject: [PATCH] documents/images: Support partial match on search | |
The postgres_search backend currently doesn't support partial searches | |
in its search() method. The index and the autocomplete method, however | |
do. | |
Enable partial matches for wagtails backend view and chooser by using | |
.autocomplete instead of .search. | |
This is a workaround and should be replaced by a cleaner approach. | |
--- | |
lib/python3.7/site-packages/wagtail/documents/views/chooser.py | 2 +- | |
.../site-packages/wagtail/documents/views/documents.py | 2 +- | |
lib/python3.7/site-packages/wagtail/images/views/chooser.py | 2 +- | |
lib/python3.7/site-packages/wagtail/images/views/images.py | 2 +- | |
4 files changed, 4 insertions(+), 4 deletions(-) | |
diff --git a/lib/python3.7/site-packages/wagtail/documents/views/chooser.py b/lib/python3.7/site-packages/wagtail/documents/views/chooser.py | |
index 6adc3aa..dee0087 100644 | |
--- a/lib/python3.7/site-packages/wagtail/documents/views/chooser.py | |
+++ b/lib/python3.7/site-packages/wagtail/documents/views/chooser.py | |
@@ -71,7 +71,7 @@ def chooser(request): | |
if searchform.is_valid(): | |
q = searchform.cleaned_data['q'] | |
- documents = documents.search(q) | |
+ documents = documents.autocomplete(q) | |
is_searching = True | |
else: | |
documents = documents.order_by('-created_at') | |
diff --git a/lib/python3.7/site-packages/wagtail/documents/views/documents.py b/lib/python3.7/site-packages/wagtail/documents/views/documents.py | |
index 4ce20fe..1228b95 100644 | |
--- a/lib/python3.7/site-packages/wagtail/documents/views/documents.py | |
+++ b/lib/python3.7/site-packages/wagtail/documents/views/documents.py | |
@@ -55,7 +55,7 @@ def index(request): | |
form = SearchForm(request.GET, placeholder=_("Search documents")) | |
if form.is_valid(): | |
query_string = form.cleaned_data['q'] | |
- documents = documents.search(query_string) | |
+ documents = documents.autocomplete(query_string) | |
else: | |
form = SearchForm(placeholder=_("Search documents")) | |
diff --git a/lib/python3.7/site-packages/wagtail/images/views/chooser.py b/lib/python3.7/site-packages/wagtail/images/views/chooser.py | |
index b36095e..b576f5d 100644 | |
--- a/lib/python3.7/site-packages/wagtail/images/views/chooser.py | |
+++ b/lib/python3.7/site-packages/wagtail/images/views/chooser.py | |
@@ -101,7 +101,7 @@ def chooser(request): | |
if searchform.is_valid(): | |
q = searchform.cleaned_data['q'] | |
- images = images.search(q) | |
+ images = images.autocomplete(q) | |
is_searching = True | |
else: | |
is_searching = False | |
diff --git a/lib/python3.7/site-packages/wagtail/images/views/images.py b/lib/python3.7/site-packages/wagtail/images/views/images.py | |
index edb1c40..e030224 100644 | |
--- a/lib/python3.7/site-packages/wagtail/images/views/images.py | |
+++ b/lib/python3.7/site-packages/wagtail/images/views/images.py | |
@@ -48,7 +48,7 @@ def index(request): | |
if form.is_valid(): | |
query_string = form.cleaned_data['q'] | |
- images = images.search(query_string) | |
+ images = images.autocomplete(query_string) | |
else: | |
form = SearchForm(placeholder=_("Search images")) | |
-- | |
2.26.2 | |