Mercurial > public > sg101
comparison 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 |
comparison
equal
deleted
inserted
replaced
468:ad4b63fbc584 | 469:3b30286adba5 |
---|---|
1 """ | |
2 This module contains custom forms to tailor the Haystack search application to | |
3 our needs. | |
4 | |
5 """ | |
6 from django import forms | |
7 from haystack.forms import ModelSearchForm | |
8 | |
9 | |
10 MODEL_CHOICES = ( | |
11 ('forums.topic', 'Forum Topics'), | |
12 ('forums.post', 'Forum Posts'), | |
13 ('news.story', 'News Stories'), | |
14 ('bio.userprofile', 'User Profiles'), | |
15 ('weblinks.link', 'Links'), | |
16 ('downloads.download', 'Downloads'), | |
17 ('podcast.item', 'Podcasts'), | |
18 ('ygroup.post', 'Yahoo Group Archives'), | |
19 ) | |
20 | |
21 | |
22 class CustomModelSearchForm(ModelSearchForm): | |
23 """ | |
24 This customized ModelSearchForm allows us to explictly label and order | |
25 the model choices. | |
26 | |
27 """ | |
28 q = forms.CharField(required=False, label='', | |
29 widget=forms.TextInput(attrs={'class': 'text', 'size': 48})) | |
30 | |
31 def __init__(self, *args, **kwargs): | |
32 super(CustomModelSearchForm, self).__init__(*args, **kwargs) | |
33 self.fields['models'] = forms.MultipleChoiceField(choices=MODEL_CHOICES, | |
34 label='', widget=forms.CheckboxSelectMultiple) |