summaryrefslogtreecommitdiff
path: root/helsinki/program/search_indexes.py
blob: 8c21e140ffbfacc775bb337353b3a9e8156f3562 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from haystack.indexes import CharField, DateTimeField, SearchIndex
from haystack import site

from datetime import datetime

from program.models import Note, Show

class NoteIndex(SearchIndex):
    text = CharField(document=True, use_template=True)
    last_updated = DateTimeField(model_attr='last_updated')

    def get_queryset(self):
        return Note.objects.filter(last_updated__lte=datetime.now())

class ShowIndex(SearchIndex):
    text = CharField(document=True, use_template=True)
    last_updated = DateTimeField(model_attr='last_updated')

    def get_queryset(self):
        return Show.objects.filter(last_updated__lte=datetime.now())

site.register(Note, NoteIndex)
site.register(Show, ShowIndex)