X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/4668015907cd146c6607ba4a14611f4ea7ffe617..972f33fb2d98a9ff59c931ac6a8a82def7cea6fe:/src/search/forms.py diff --git a/src/search/forms.py b/src/search/forms.py index 176c73ee8..dee9c7774 100644 --- a/src/search/forms.py +++ b/src/search/forms.py @@ -10,24 +10,10 @@ from catalogue.constants import LANGUAGES_3TO2 import catalogue.models import pdcounter.models import picture.models -from .fields import JQueryAutoCompleteSearchField, InlineRadioWidget +from .fields import InlineRadioWidget from .utils import UnaccentSearchQuery, UnaccentSearchVector -class SearchForm(forms.Form): - q = JQueryAutoCompleteSearchField(label=_('Search')) - # {'minChars': 2, 'selectFirst': True, 'cacheLength': 50, 'matchContains': "word"}) - - def __init__(self, source, *args, **kwargs): - kwargs['auto_id'] = False - super(SearchForm, self).__init__(*args, **kwargs) - self.fields['q'].widget.attrs['id'] = 'search' - self.fields['q'].widget.attrs['autocomplete'] = 'off' - self.fields['q'].widget.attrs['data-source'] = source - if 'q' not in self.data: - self.fields['q'].widget.attrs['placeholder'] = _('title, author, epoch, kind, genre, phrase') - - class SearchFilters(forms.Form): q = forms.CharField( required=False, widget=forms.HiddenInput(), @@ -158,8 +144,8 @@ class SearchFilters(forms.Form): def results(self): qs = self.get_querysets() query = self.cleaned_data['q'] - squery = UnaccentSearchQuery(query, config='polish') - query = SearchQuery(query, config='polish') + squery = UnaccentSearchQuery(query, config=settings.SEARCH_CONFIG) + query = SearchQuery(query, config=settings.SEARCH_CONFIG) books = qs['book'].annotate( search_vector=UnaccentSearchVector('title') ).filter(search_vector=squery) @@ -169,7 +155,7 @@ class SearchFilters(forms.Form): headline=SearchHeadline( 'text', query, - config='polish', + config=settings.SEARCH_CONFIG, start_sel='', stop_sel='', )