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 936890e
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions patches/hack-snippets-chooser-to-use-autocomplete.patch
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

0 comments on commit 936890e

Please sign in to comment.