+def hint(request):
+ prefix = request.GET.get('term', '')
+ if len(prefix) < 2:
+ return JSONResponse([])
+ JVM.attachCurrentThread()
+ s = Search()
+
+ hint = s.hint()
+ try:
+ tags = request.GET.get('tags', '')
+ hint.tags(Tag.get_tag_list(tags))
+ except:
+ pass
+
+ # tagi beda ograniczac tutaj
+ # ale tagi moga byc na ksiazce i na fragmentach
+ # jezeli tagi dot tylko ksiazki, to wazne zeby te nowe byly w tej samej ksiazce
+ # jesli zas dotycza themes, to wazne, zeby byly w tym samym fragmencie.
+
+ tags = s.hint_tags(prefix)
+ books = s.hint_books(prefix)
+
+ # TODO DODAC TU HINTY
+
+ return JSONResponse(
+ [{'label': t.name,
+ 'category': _(t.category),
+ 'id': t.id,
+ 'url': t.get_absolute_url()}
+ for t in tags] + \
+ [{'label': b.title,
+ 'category': _('book'),
+ 'id': b.id,
+ 'url': b.get_absolute_url()}
+ for b in books])
+
+