Fix blog api url to the one used by apps.
[wolnelektury.git] / src / search / forms.py
1 # -*- coding: utf-8 -*-
2 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
4 #
5 from django import forms
6 from django.utils.translation import ugettext_lazy as _
7
8 from search.fields import JQueryAutoCompleteSearchField
9
10
11 class SearchForm(forms.Form):
12     q = JQueryAutoCompleteSearchField(label=_('Search'))
13     # {'minChars': 2, 'selectFirst': True, 'cacheLength': 50, 'matchContains': "word"})
14
15     def __init__(self, source, *args, **kwargs):
16         kwargs['auto_id'] = False
17         super(SearchForm, self).__init__(*args, **kwargs)
18         self.fields['q'].widget.attrs['id'] = 'search'
19         self.fields['q'].widget.attrs['autocomplete'] = 'off'
20         self.fields['q'].widget.attrs['data-source'] = source
21         if 'q' not in self.data:
22             self.fields['q'].widget.attrs['placeholder'] = _('title, author, theme/topic, epoch, kind, genre, phrase')