annotate gpp/custom_search.py @ 459:9d3bd7304050
Fixing #221. Also combined all permissions checks into a new module, permissions.py. This allows us to cache user, category, and forum groups information since it rarely changes.
author |
Brian Neal <bgneal@gmail.com> |
date |
Sat, 02 Jul 2011 23:35:45 +0000 |
parents |
524fd1b3919a |
children |
b910cc1460c8 |
rev |
line source |
bgneal@415
|
1 """
|
bgneal@415
|
2 This module contains custom code to tailor the Haystack search application to
|
bgneal@415
|
3 our needs.
|
bgneal@415
|
4
|
bgneal@415
|
5 """
|
bgneal@415
|
6 import urllib
|
bgneal@415
|
7
|
bgneal@415
|
8 from django import forms
|
bgneal@415
|
9 from haystack.forms import ModelSearchForm
|
bgneal@415
|
10
|
bgneal@415
|
11
|
bgneal@415
|
12 MODEL_CHOICES = (
|
bgneal@415
|
13 ('forums.topic', 'Forum Topics'),
|
bgneal@415
|
14 ('forums.post', 'Forum Posts'),
|
bgneal@415
|
15 ('news.story', 'News Stories'),
|
bgneal@415
|
16 ('bio.userprofile', 'User Profiles'),
|
bgneal@415
|
17 ('weblinks.link', 'Links'),
|
bgneal@415
|
18 ('downloads.download', 'Downloads'),
|
bgneal@415
|
19 ('podcast.item', 'Podcasts'),
|
bgneal@415
|
20 ('ygroup.post', 'Yahoo Group Archives'),
|
bgneal@415
|
21 )
|
bgneal@415
|
22
|
bgneal@415
|
23
|
bgneal@415
|
24 class CustomModelSearchForm(ModelSearchForm):
|
bgneal@415
|
25 """
|
bgneal@415
|
26 This customized ModelSearchForm allows us to explictly label and order
|
bgneal@415
|
27 the model choices.
|
bgneal@415
|
28
|
bgneal@415
|
29 """
|
bgneal@415
|
30 q = forms.CharField(required=False, label='',
|
bgneal@415
|
31 widget=forms.TextInput(attrs={'class': 'text', 'size': 48}))
|
bgneal@415
|
32
|
bgneal@415
|
33 def __init__(self, *args, **kwargs):
|
bgneal@415
|
34 super(CustomModelSearchForm, self).__init__(*args, **kwargs)
|
bgneal@415
|
35 self.fields['models'] = forms.MultipleChoiceField(choices=MODEL_CHOICES,
|
bgneal@415
|
36 label='', widget=forms.CheckboxSelectMultiple)
|