annotate custom_search/forms.py @ 752:95f4e7f352fd
For Django 1.6: contrib auth password reset confirm view signature changed.
The uidb64 parameter was previously base 36 encoded and named uidb36.
Had to update urls.py. While I was in there I decided to make the
password reset email use the {% url %} tag to be more resilient if the
url changes.
author |
Brian Neal <bgneal@gmail.com> |
date |
Wed, 01 Jan 2014 19:52:07 -0600 |
parents |
99d7bf8cd712 |
children |
ad53d929281a |
rev |
line source |
bgneal@469
|
1 """
|
bgneal@469
|
2 This module contains custom forms to tailor the Haystack search application to
|
bgneal@469
|
3 our needs.
|
bgneal@469
|
4
|
bgneal@469
|
5 """
|
bgneal@469
|
6 from django import forms
|
bgneal@469
|
7 from haystack.forms import ModelSearchForm
|
bgneal@469
|
8
|
bgneal@469
|
9
|
bgneal@469
|
10 MODEL_CHOICES = (
|
bgneal@469
|
11 ('forums.topic', 'Forum Topics'),
|
bgneal@469
|
12 ('forums.post', 'Forum Posts'),
|
bgneal@469
|
13 ('news.story', 'News Stories'),
|
bgneal@469
|
14 ('bio.userprofile', 'User Profiles'),
|
bgneal@469
|
15 ('weblinks.link', 'Links'),
|
bgneal@469
|
16 ('downloads.download', 'Downloads'),
|
bgneal@469
|
17 ('podcast.item', 'Podcasts'),
|
bgneal@469
|
18 ('ygroup.post', 'Yahoo Group Archives'),
|
bgneal@469
|
19 )
|
bgneal@469
|
20
|
bgneal@469
|
21
|
bgneal@469
|
22 class CustomModelSearchForm(ModelSearchForm):
|
bgneal@469
|
23 """
|
bgneal@469
|
24 This customized ModelSearchForm allows us to explictly label and order
|
bgneal@469
|
25 the model choices.
|
bgneal@469
|
26
|
bgneal@469
|
27 """
|
bgneal@469
|
28 q = forms.CharField(required=False, label='',
|
bgneal@729
|
29 widget=forms.TextInput(attrs={'type': 'search',
|
bgneal@729
|
30 'class': 'search',
|
bgneal@729
|
31 'size': 48,
|
bgneal@729
|
32 }))
|
bgneal@469
|
33
|
bgneal@469
|
34 def __init__(self, *args, **kwargs):
|
bgneal@469
|
35 super(CustomModelSearchForm, self).__init__(*args, **kwargs)
|
bgneal@469
|
36 self.fields['models'] = forms.MultipleChoiceField(choices=MODEL_CHOICES,
|
bgneal@469
|
37 label='', widget=forms.CheckboxSelectMultiple)
|