src/p4l/search/forms.py
changeset 115 4749704f9b40
parent 113 c05567404888
child 126 a345f1a67bf1
equal deleted inserted replaced
114:93b45b4f423c 115:4749704f9b40
     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