summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2018-09-09 07:07:25 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2018-09-10 13:35:11 (GMT)
commit88382da422e8f3af0e19d2c25e17a9454642ec21 (patch)
treeeedf736e93ed8f56e58a2e95ebb42dda32a7e64c
parent596dfe767899ffcd8521aea4b88c9a288e465b54 (diff)
downloadcombo-88382da422e8f3af0e19d2c25e17a9454642ec21.zip
combo-88382da422e8f3af0e19d2c25e17a9454642ec21.tar.gz
combo-88382da422e8f3af0e19d2c25e17a9454642ec21.tar.bz2
search: allow passing request user to search engines (#26254)
-rw-r--r--combo/apps/search/models.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/combo/apps/search/models.py b/combo/apps/search/models.py
index cac995a..fc8e56d 100644
--- a/combo/apps/search/models.py
+++ b/combo/apps/search/models.py
@@ -129,7 +129,8 @@ class SearchCell(CellBase):
if not query:
return render_response(service)
- url = get_templated_url(service['url'], context={'q': query, 'search_service': service})
+ url = get_templated_url(service['url'],
+ context={'request': request, 'q': query, 'search_service': service})
url = url % {'q': quote(query.encode('utf-8'))} # if url contains %(q)s
if url.startswith('/'):
url = request.build_absolute_uri(url)
@@ -140,6 +141,10 @@ class SearchCell(CellBase):
kwargs = {}
kwargs['cache_duration'] = service.get('cache_duration', 0)
kwargs['remote_service'] = 'auto' if service.get('signature') else None
+ # don't automatically add user info to query string, if required it can
+ # be set explicitely in the URL template in the engine definition (via
+ # {{user_nameid}} or {{user_email}}).
+ kwargs['without_user'] = True
results = requests.get(url, **kwargs).json()
hit_templates = {}
if service.get('hit_url_template'):