X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/9891ea5fbf1f70686612a66fcb6bdfc04a9a037c..a7f1c123425b68bd1cd9ccd74fd8b048d9b525b1:/src/search/views.py diff --git a/src/search/views.py b/src/search/views.py index 970734ad7..da3a767f8 100644 --- a/src/search/views.py +++ b/src/search/views.py @@ -59,8 +59,8 @@ def did_you_mean(query, tokens): @cache.never_cache -def hint(request): - prefix = request.GET.get('term', '') +def hint(request, mozhint=False, param='term'): + prefix = request.GET.get(param, '') if len(prefix) < 2: return JsonResponse([], safe=False) @@ -94,6 +94,16 @@ def hint(request): } for b in Book.objects.filter(findable=True, title__iregex='\m' + prefix)[:limit-len(data)] ] + + if mozhint: + data = [ + prefix, + [ + item['label'] + for item in data + ] + ] + callback = request.GET.get('callback', None) if callback: return HttpResponse("%s(%s);" % (callback, json.dumps(data)),