-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a patch for snippet chooser autocomplete
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
From 1ddccbd08e5109b6dae2d18737fa920509752d83 Mon Sep 17 00:00:00 2001 | ||
From: Donald Buczek <buczek@molgen.mpg.de> | ||
Date: Tue, 19 Nov 2019 15:27:16 +0100 | ||
Subject: [PATCH] Hack snippets chooser to use autocomplete | ||
|
||
Users wanted to have partial search when Contacts are selected by the | ||
Chooser. The Chooser doesn't have the feature to use partial matches and | ||
our postgres_search doesn't support it in its search() method anyway. | ||
Try to get away with changing the Chooserd to use autocomplete(). | ||
--- | ||
lib/python3.7/site-packages/wagtail/snippets/views/chooser.py | 3 ++- | ||
1 file changed, 2 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/lib/python3.7/site-packages/wagtail/snippets/views/chooser.py b/lib/python3.7/site-packages/wagtail/snippets/views/chooser.py | ||
index adffdef..f87a2d4 100644 | ||
--- a/lib/python3.7/site-packages/wagtail/snippets/views/chooser.py | ||
+++ b/lib/python3.7/site-packages/wagtail/snippets/views/chooser.py | ||
@@ -10,6 +10,7 @@ from wagtail.search.backends import get_search_backend | ||
from wagtail.search.index import class_is_indexed | ||
from wagtail.snippets.views.snippets import get_snippet_model_from_url_params | ||
|
||
+from donald import * | ||
|
||
def choose(request, app_label, model_name): | ||
model = get_snippet_model_from_url_params(app_label, model_name) | ||
@@ -34,7 +35,7 @@ def choose(request, app_label, model_name): | ||
search_query = search_form.cleaned_data['q'] | ||
|
||
search_backend = get_search_backend() | ||
- items = search_backend.search(search_query, items) | ||
+ items = search_backend.autocomplete(search_query, items) | ||
is_searching = True | ||
|
||
else: | ||
-- | ||
2.22.0 | ||
|