From 1801c65004af14a8ed50d60e47d75a415753bbf7 Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Fri, 15 Dec 2017 17:44:05 +0100 Subject: [PATCH] minor changes in search --- src/search/context_processors.py | 2 +- src/search/views.py | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/search/context_processors.py b/src/search/context_processors.py index 6ad2fe9e2..63e328583 100644 --- a/src/search/context_processors.py +++ b/src/search/context_processors.py @@ -7,4 +7,4 @@ from search.forms import SearchForm def search_form(request): - return {'search_form': SearchForm(reverse('search.views.hint')+'?max=10', request.GET)} + return {'search_form': SearchForm(reverse('search_hint') + '?max=10', request.GET)} diff --git a/src/search/views.py b/src/search/views.py index 8542e512f..64382e24b 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 @@ -76,20 +74,20 @@ def hint(request): if limit < 1: limit = 20 + authors = Tag.objects.filter( + category='author', name__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)[:limit] + for author in authors[:limit] ] if len(data) < limit: data += [ { 'label': '%s, %s' % (b.title, b.author_unicode()), - 'category': _('book'), 'id': b.id, 'url': b.get_absolute_url() } -- 2.20.1