bgneal@222: """Haystack search index for the weblinks application.""" bgneal@753: from haystack import indexes bgneal@222: bgneal@414: from forums.models import Forum, Topic, Post bgneal@414: bgneal@414: bgneal@753: class TopicIndex(indexes.SearchIndex, indexes.Indexable): bgneal@753: text = indexes.CharField(document=True, use_template=True) bgneal@753: author = indexes.CharField(model_attr='user') bgneal@753: pub_date = indexes.DateTimeField(model_attr='creation_date') bgneal@414: bgneal@753: def get_model(self): bgneal@753: return Topic bgneal@753: bgneal@753: def index_queryset(self, using=None): 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@469: bgneal@753: class PostIndex(indexes.SearchIndex, indexes.Indexable): bgneal@753: text = indexes.CharField(document=True, use_template=True) bgneal@753: author = indexes.CharField(model_attr='user') bgneal@753: pub_date = indexes.DateTimeField(model_attr='creation_date') bgneal@469: bgneal@753: def get_model(self): bgneal@753: return Post bgneal@470: bgneal@753: def index_queryset(self, using=None): 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'