models: Remove "cleared" and "processed" fields from Jobs.
[ganeti_webmgr.git] / ganeti_web / forms / autocomplete_search_form.py
bloba01cde2b3c19795a8e0f0730c14996f1937afef3
1 # Custom Haystack search form for autocomplete searches
3 from haystack.forms import SearchForm
6 class autocomplete_search_form(SearchForm):
7 '''
8 Custom Haystack search form for autocomplete searches. Important so that
9 users can search for 'foo' and get 'foo.bar', 'foo.bar.herp', etc.
10 '''
11 def search(self):
12 '''
13 Overwriting SearchForm's default search to implement autocomplete
14 searching.
15 '''
16 if not self.is_valid():
17 return self.no_query_found()
19 if not self.cleaned_data.get('q'):
20 return self.no_query_found()
22 # Perform an autocomplete search query on the 'content_auto' fields of
23 # the searchable models
24 sqs = self.searchqueryset.autocomplete(content_auto=self.cleaned_data['q'])
26 if self.load_all:
27 sqs = sqs.load_all()
29 return sqs