equal
deleted
inserted
replaced
4 |
4 |
5 @author: ymh |
5 @author: ymh |
6 ''' |
6 ''' |
7 from haystack.forms import SearchForm |
7 from haystack.forms import SearchForm |
8 |
8 |
|
9 from p4l.models.data import Record |
|
10 from p4l.search.query_parser import QueryParser |
9 from p4l.utils import strip_accents |
11 from p4l.utils import strip_accents |
10 |
12 |
11 |
13 |
12 class RecordSearchForm(SearchForm): |
14 class RecordSearchForm(SearchForm): |
13 |
15 |
22 return self.no_query_found() |
24 return self.no_query_found() |
23 |
25 |
24 if not self.cleaned_data.get('q'): |
26 if not self.cleaned_data.get('q'): |
25 return self.no_query_found() |
27 return self.no_query_found() |
26 |
28 |
27 sqs = self.searchqueryset.auto_query(strip_accents(self.cleaned_data['q'])) |
29 qp = QueryParser("text") |
|
30 sqs = self.searchqueryset.models(Record).filter(qp.parse(strip_accents(self.cleaned_data['q']))) |
28 |
31 |
29 if self.load_all: |
32 if self.load_all: |
30 sqs = sqs.load_all() |
33 sqs = sqs.load_all() |
31 |
34 |
32 return sqs |
35 return sqs |