From e88087eece7104820b60bb11573b579bbb36c01d Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Sun, 3 Apr 2011 00:24:41 +0200 Subject: added search indexes and templates. diff --git a/program/search_indexes.py b/program/search_indexes.py new file mode 100644 index 0000000..8c21e14 --- /dev/null +++ b/program/search_indexes.py @@ -0,0 +1,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) \ No newline at end of file diff --git a/search_sites.py b/search_sites.py new file mode 100644 index 0000000..fe5127a --- /dev/null +++ b/search_sites.py @@ -0,0 +1,2 @@ +import haystack +haystack.autodiscover() \ No newline at end of file diff --git a/templates/search/indexes/program/note_text.txt b/templates/search/indexes/program/note_text.txt new file mode 100644 index 0000000..2421b4f --- /dev/null +++ b/templates/search/indexes/program/note_text.txt @@ -0,0 +1,2 @@ +{{ object.title }} +{{ object.content }} \ No newline at end of file diff --git a/templates/search/indexes/program/show_text.txt b/templates/search/indexes/program/show_text.txt new file mode 100644 index 0000000..f08b515 --- /dev/null +++ b/templates/search/indexes/program/show_text.txt @@ -0,0 +1,3 @@ +{{ object.name }} +{{ object.description }} +{{ object.short_description }} \ No newline at end of file -- cgit v0.10.2