From f487c5408ccad2bc6195b2165476442884c85c1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Thu, 9 Aug 2018 10:31:20 +0200 Subject: [PATCH] search: add possibility to specify a hit url template (#25614) --- combo/apps/search/models.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/combo/apps/search/models.py b/combo/apps/search/models.py index a1e0885..e5d8583 100644 --- a/combo/apps/search/models.py +++ b/combo/apps/search/models.py @@ -21,6 +21,7 @@ from django.http import HttpResponse from django.core.exceptions import PermissionDenied from django.core.urlresolvers import reverse from django.utils.http import quote +from django.template import Context, Template from jsonfield import JSONField @@ -132,4 +133,8 @@ class SearchCell(CellBase): kwargs['cache_duration'] = service.get('cache_duration', 0) kwargs['remote_service'] = 'auto' if service.get('signature') else None results = requests.get(url, **kwargs).json() + if service.get('hit_url'): + hit_url_template = Template(service['hit_url']) + for hit in results.get('data'): + hit['url'] = hit_url_template.render(Context(hit)) return render_response(service, results) -- 2.18.0