Mercurial > public > sg101
diff gpp/custom_search/forms.py @ 469:3b30286adba5
Smarter search index updating for forums. This work is for #227.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 17 Aug 2011 01:02:08 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gpp/custom_search/forms.py Wed Aug 17 01:02:08 2011 +0000 @@ -0,0 +1,34 @@ +""" +This module contains custom forms to tailor the Haystack search application to +our needs. + +""" +from django import forms +from haystack.forms import ModelSearchForm + + +MODEL_CHOICES = ( + ('forums.topic', 'Forum Topics'), + ('forums.post', 'Forum Posts'), + ('news.story', 'News Stories'), + ('bio.userprofile', 'User Profiles'), + ('weblinks.link', 'Links'), + ('downloads.download', 'Downloads'), + ('podcast.item', 'Podcasts'), + ('ygroup.post', 'Yahoo Group Archives'), +) + + +class CustomModelSearchForm(ModelSearchForm): + """ + This customized ModelSearchForm allows us to explictly label and order + the model choices. + + """ + q = forms.CharField(required=False, label='', + widget=forms.TextInput(attrs={'class': 'text', 'size': 48})) + + def __init__(self, *args, **kwargs): + super(CustomModelSearchForm, self).__init__(*args, **kwargs) + self.fields['models'] = forms.MultipleChoiceField(choices=MODEL_CHOICES, + label='', widget=forms.CheckboxSelectMultiple)