comparison bio/search_indexes.py @ 581:ee87ea74d46b

For Django 1.4, rearranged project structure for new manage.py.
author Brian Neal <bgneal@gmail.com>
date Sat, 05 May 2012 17:10:48 -0500
parents gpp/bio/search_indexes.py@98b373ca09f3
children ad53d929281a
comparison
equal deleted inserted replaced
580:c525f3e0b5d0 581:ee87ea74d46b
1 """Haystack search index for the bio application."""
2 from haystack.indexes import *
3 from haystack import site
4 from custom_search.indexes import CondQueuedSearchIndex
5
6 from bio.models import UserProfile
7 from bio.signals import profile_content_update
8
9
10 class UserProfileIndex(CondQueuedSearchIndex):
11 text = CharField(document=True, use_template=True)
12 author = CharField(model_attr='user')
13
14 def index_queryset(self):
15 return UserProfile.objects.filter(user__is_active=True)
16
17 def get_updated_field(self):
18 return 'update_date'
19
20 def _setup_save(self, model):
21 profile_content_update.connect(self.enqueue_save)
22
23 def _teardown_save(self, model):
24 profile_content_update.disconnect(self.enqueue_save)
25
26 def enqueue_save(self, sender, **kwargs):
27 return self.enqueue('update', sender)
28
29
30 site.register(UserProfile, UserProfileIndex)