import datetime
from haystack.indexes import *
from haystack import site
from newsroom.models import Story, Editorial


class StoryIndex(SearchIndex):
    title = CharField(model_attr="title")
    body = CharField(document=True, use_template=True)
    published_on = DateTimeField()

    def get_queryset(self):
        """Used when the entire index for model is updated."""
        return Story.objects.filter(published_on__lte=datetime.datetime.now())


site.register(Story, StoryIndex)
