from catalogue.models import Book
from catalogue import views
import picture.views
+import search.views
urlpatterns = [
path('lektury/<slug:slug>/', views.collection, name='collection'),
path('audiobooki/', views.audiobooks, name='audiobook_list'),
path('daisy/', views.daisy_list, name='daisy_list'),
+ path('jtags/', search.views.hint, {'param': 'q', 'mozhint': True}, name='jhint'),
path('nowe/', ListView.as_view(
queryset=Book.objects.filter(parent=None, findable=True).order_by('-created_at'),
template_name='catalogue/recent_list.html'), name='recent_list'),
@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)
}
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)),