X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/5105e426102784140df92c6a6ce1ffdf70866a4e..86569c70ff1da103f898e4e9668f3f3babb4833a:/src/search/views.py diff --git a/src/search/views.py b/src/search/views.py index b0f064119..7e512be14 100644 --- a/src/search/views.py +++ b/src/search/views.py @@ -7,11 +7,9 @@ from django.shortcuts import render_to_response from django.template import RequestContext from django.views.decorators import cache from django.http import HttpResponse, JsonResponse -from django.utils.translation import ugettext as _ from catalogue.utils import split_tags from catalogue.models import Book, Tag -from pdcounter.models import Author as PDCounterAuthor, BookStub as PDCounterBook from search.index import Search, SearchResult from suggest.forms import PublishingSuggestForm import re @@ -71,25 +69,26 @@ def hint(request): try: limit = int(request.GET.get('max', '')) except ValueError: - limit = -1 + limit = 20 else: if limit < 1: - limit = -1 + limit = 20 + authors = Tag.objects.filter( + category='author', name_pl__iregex='\m' + prefix).only('name', 'id', 'slug', 'category') data = [ { 'label': author.name, - 'category': _('author'), 'id': author.id, 'url': author.get_absolute_url(), } - for author in Tag.objects.filter(category='author', name__iregex=u'\m' + prefix)[:10] + for author in authors[:limit] ] if len(data) < limit: data += [ { - 'label': '%s, %s' % (b.title, b.author_unicode()), - 'category': _('book'), + 'label': b.title, + 'author': b.author_unicode(), 'id': b.id, 'url': b.get_absolute_url() }