bgneal@469: """ bgneal@469: This module contains custom forms to tailor the Haystack search application to bgneal@469: our needs. bgneal@469: bgneal@469: """ bgneal@469: from django import forms bgneal@469: from haystack.forms import ModelSearchForm bgneal@469: bgneal@469: bgneal@469: MODEL_CHOICES = ( bgneal@469: ('forums.topic', 'Forum Topics'), bgneal@469: ('forums.post', 'Forum Posts'), bgneal@469: ('news.story', 'News Stories'), bgneal@469: ('bio.userprofile', 'User Profiles'), bgneal@469: ('weblinks.link', 'Links'), bgneal@469: ('downloads.download', 'Downloads'), bgneal@469: ('podcast.item', 'Podcasts'), bgneal@469: ('ygroup.post', 'Yahoo Group Archives'), bgneal@469: ) bgneal@469: bgneal@469: bgneal@469: class CustomModelSearchForm(ModelSearchForm): bgneal@469: """ bgneal@469: This customized ModelSearchForm allows us to explictly label and order bgneal@469: the model choices. bgneal@469: bgneal@469: """ bgneal@469: q = forms.CharField(required=False, label='', bgneal@469: widget=forms.TextInput(attrs={'class': 'text', 'size': 48})) bgneal@469: bgneal@469: def __init__(self, *args, **kwargs): bgneal@469: super(CustomModelSearchForm, self).__init__(*args, **kwargs) bgneal@469: self.fields['models'] = forms.MultipleChoiceField(choices=MODEL_CHOICES, bgneal@469: label='', widget=forms.CheckboxSelectMultiple)