bgneal@222: """Haystack search index for the weblinks application.""" bgneal@222: from haystack.indexes import * bgneal@222: from haystack import site bgneal@392: from queued_search.indexes import QueuedSearchIndex bgneal@222: bgneal@414: from forums.models import Forum, Topic, Post bgneal@414: bgneal@414: bgneal@414: class TopicIndex(QueuedSearchIndex): bgneal@414: text = CharField(document=True, use_template=True) bgneal@414: author = CharField(model_attr='user') bgneal@414: pub_date = DateTimeField(model_attr='creation_date') bgneal@414: bgneal@414: def get_queryset(self): bgneal@414: return Topic.objects.filter(forum__in=Forum.objects.public_forum_ids()) bgneal@414: bgneal@414: def get_updated_field(self): bgneal@414: return 'update_date' bgneal@222: bgneal@222: bgneal@392: class PostIndex(QueuedSearchIndex): bgneal@222: text = CharField(document=True, use_template=True) bgneal@222: author = CharField(model_attr='user') bgneal@222: pub_date = DateTimeField(model_attr='creation_date') bgneal@222: bgneal@222: def get_queryset(self): bgneal@222: return Post.objects.filter( bgneal@414: topic__forum__in=Forum.objects.public_forum_ids()) bgneal@222: bgneal@277: def get_updated_field(self): bgneal@277: return 'update_date' bgneal@277: bgneal@222: bgneal@414: site.register(Topic, TopicIndex) bgneal@222: site.register(Post, PostIndex)