annotate gpp/forums/search_indexes.py @ 425:76ba9478ebbd

Initial beta-test commit of a revamped, jquery ui tab-based PM system. This is for #211.
author Brian Neal <bgneal@gmail.com>
date Tue, 26 Apr 2011 00:16:35 +0000
parents b1f939b1fb01
children b910cc1460c8
rev   line source
bgneal@222 1 """Haystack search index for the weblinks application."""
bgneal@222 2 from haystack.indexes import *
bgneal@222 3 from haystack import site
bgneal@392 4 from queued_search.indexes import QueuedSearchIndex
bgneal@222 5
bgneal@414 6 from forums.models import Forum, Topic, Post
bgneal@414 7
bgneal@414 8
bgneal@414 9 class TopicIndex(QueuedSearchIndex):
bgneal@414 10 text = CharField(document=True, use_template=True)
bgneal@414 11 author = CharField(model_attr='user')
bgneal@414 12 pub_date = DateTimeField(model_attr='creation_date')
bgneal@414 13
bgneal@414 14 def get_queryset(self):
bgneal@414 15 return Topic.objects.filter(forum__in=Forum.objects.public_forum_ids())
bgneal@414 16
bgneal@414 17 def get_updated_field(self):
bgneal@414 18 return 'update_date'
bgneal@222 19
bgneal@222 20
bgneal@392 21 class PostIndex(QueuedSearchIndex):
bgneal@222 22 text = CharField(document=True, use_template=True)
bgneal@222 23 author = CharField(model_attr='user')
bgneal@222 24 pub_date = DateTimeField(model_attr='creation_date')
bgneal@222 25
bgneal@222 26 def get_queryset(self):
bgneal@222 27 return Post.objects.filter(
bgneal@414 28 topic__forum__in=Forum.objects.public_forum_ids())
bgneal@222 29
bgneal@277 30 def get_updated_field(self):
bgneal@277 31 return 'update_date'
bgneal@277 32
bgneal@222 33
bgneal@414 34 site.register(Topic, TopicIndex)
bgneal@222 35 site.register(Post, PostIndex)