diff gpp/custom_search.py @ 438:524fd1b3919a

Fixing #214; don't need a custom model search view. All the info is in the template. Wrote a template tag to extract the info from the request context and urlencode them.
author Brian Neal <bgneal@gmail.com>
date Wed, 18 May 2011 03:04:25 +0000
parents d4d167876c25
children b910cc1460c8
line wrap: on
line diff
--- a/gpp/custom_search.py	Sat May 14 19:02:07 2011 +0000
+++ b/gpp/custom_search.py	Wed May 18 03:04:25 2011 +0000
@@ -6,7 +6,6 @@
 import urllib
 
 from django import forms
-from haystack.views import SearchView
 from haystack.forms import ModelSearchForm
 
 
@@ -35,31 +34,3 @@
         super(CustomModelSearchForm, self).__init__(*args, **kwargs)
         self.fields['models'] = forms.MultipleChoiceField(choices=MODEL_CHOICES,
                 label='', widget=forms.CheckboxSelectMultiple)
-
-
-class ModelSearchView(SearchView):
-    """
-    This custom search view puts an extra value in the template context named
-    search_parms. search_parms will contain the search term q plus any models
-    arguments all as a urlencoded string. This is useful for generating
-    pagination links in the template.
-
-    """
-    def search_params(self):
-        """
-        Return the q and models search parameters as a urlencoded string if the
-        form is valid. An empty string is returned if the form is not valid.
-
-        """
-        if self.form.is_valid():
-            q = self.form.cleaned_data['q']
-            models = self.form.cleaned_data['models']
-
-            params = [('q', q)]
-            params.extend([('models', model) for model in models])
-            return urllib.urlencode(params)
-
-        return ''
-
-    def extra_context(self):
-        return {'search_params': self.search_params() }