Mercurial > public > sg101
annotate gpp/bio/search_indexes.py @ 370:e9a066db3f54
Adding some try/except around some key points in the code to protect against some IntegrityErrors. We log when these happens but otherwise keep going. Tickets: #160 and #169.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 06 Mar 2011 00:40:50 +0000 |
parents | d424b8bae71d |
children | 79240675b903 |
rev | line source |
---|---|
bgneal@223 | 1 """Haystack search index for the bio application.""" |
bgneal@223 | 2 from haystack.indexes import * |
bgneal@223 | 3 from haystack import site |
bgneal@223 | 4 |
bgneal@223 | 5 from bio.models import UserProfile |
bgneal@223 | 6 |
bgneal@223 | 7 |
bgneal@223 | 8 class UserProfileIndex(SearchIndex): |
bgneal@223 | 9 text = CharField(document=True, use_template=True) |
bgneal@223 | 10 author = CharField(model_attr='user') |
bgneal@223 | 11 |
bgneal@223 | 12 def get_queryset(self): |
bgneal@223 | 13 return UserProfile.objects.filter(user__is_active=True) |
bgneal@223 | 14 |
bgneal@277 | 15 def get_updated_field(self): |
bgneal@277 | 16 return 'update_date' |
bgneal@277 | 17 |
bgneal@223 | 18 |
bgneal@223 | 19 site.register(UserProfile, UserProfileIndex) |