Skip to content

Commit

Permalink
Add a patch for snippet chooser autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
donald committed Nov 19, 2019
1 parent a0d4f1a commit b0a569d
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions patches/hack-snippets-chooser-to-use-autocomplete.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
From d1f371bdcb803d06447999e1cf3e934da9297168 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 | 2 +-
1 file changed, 1 insertion(+), 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..74de073 100644
--- a/lib/python3.7/site-packages/wagtail/snippets/views/chooser.py
+++ b/lib/python3.7/site-packages/wagtail/snippets/views/chooser.py
@@ -34,7 +34,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

0 comments on commit b0a569d

Please sign in to comment.