Projet

Général

Profil

0001-search-add-possibility-to-specify-a-hit-url-template.patch

Frédéric Péters, 09 août 2018 10:31

Télécharger (1,28 ko)

Voir les différences:

Subject: [PATCH] search: add possibility to specify a hit url template
 (#25614)

 combo/apps/search/models.py | 5 +++++
 1 file changed, 5 insertions(+)
combo/apps/search/models.py
21 21
from django.core.exceptions import PermissionDenied
22 22
from django.core.urlresolvers import reverse
23 23
from django.utils.http import quote
24
from django.template import Context, Template
24 25

  
25 26
from jsonfield import JSONField
26 27

  
......
132 133
        kwargs['cache_duration'] = service.get('cache_duration', 0)
133 134
        kwargs['remote_service'] = 'auto' if service.get('signature') else None
134 135
        results = requests.get(url, **kwargs).json()
136
        if service.get('hit_url'):
137
            hit_url_template = Template(service['hit_url'])
138
            for hit in results.get('data'):
139
                hit['url'] = hit_url_template.render(Context(hit))
135 140
        return render_response(service, results)
136
-