From 780e39d736d0415b727acee058dd211cd693f4e6 Mon Sep 17 00:00:00 2001 From: Sanj Date: Wed, 28 Mar 2012 01:58:28 +0530 Subject: [PATCH] search stuff --- itf/emailer/search_indexes.py | 12 ++++++++++++ itf/festival/admin.py | 11 ++++++----- itf/festival/models.py | 6 +++++- itf/pages/search_indexes.py | 12 ++++++++++++ itf/settings.py | 1 + itf/templates/modules/festival/meeting.html | 7 +++++++ .../search/indexes/emailer/emailerissue_text.txt | 8 ++++++++ itf/templates/search/indexes/pages/page_text.txt | 2 ++ itf/templates/search/search.html | 11 +++++++---- 9 files changed, 60 insertions(+), 10 deletions(-) create mode 100755 itf/emailer/search_indexes.py create mode 100755 itf/pages/search_indexes.py create mode 100644 itf/templates/search/indexes/emailer/emailerissue_text.txt create mode 100644 itf/templates/search/indexes/pages/page_text.txt diff --git a/itf/emailer/search_indexes.py b/itf/emailer/search_indexes.py new file mode 100755 index 0000000..c3b8373 --- /dev/null +++ b/itf/emailer/search_indexes.py @@ -0,0 +1,12 @@ +from haystack.indexes import * +from haystack import site +from models import EmailerIssue + + +class EmailerIssueIndex(SearchIndex): + text = CharField(document=True, use_template=True) + title = CharField(model_attr='title') + date = DateField(model_attr='date') + +site.register(EmailerIssue, EmailerIssueIndex) + diff --git a/itf/festival/admin.py b/itf/festival/admin.py index 3a3b09b..cdf1a0c 100755 --- a/itf/festival/admin.py +++ b/itf/festival/admin.py @@ -1,6 +1,8 @@ from django.contrib import admin from models import * from markitup.widgets import MarkItUpWidget +from django.contrib.contenttypes import generic +from padmavideos.models import PadmaVideo class AudioInline(admin.StackedInline): model = Audio @@ -10,7 +12,7 @@ class ImageInline(admin.StackedInline): model = Image extra = 3 -class PadmaVideoInline(admin.StackedInline): +class PadmaVideoInline(generic.GenericStackedInline): model = PadmaVideo extra = 3 @@ -26,11 +28,9 @@ class MeetingSponsorInline(admin.StackedInline): model = MeetingSponsor extra = 4 -class PadmaVideoAdmin(admin.ModelAdmin): - pass class TalkAdmin(admin.ModelAdmin): - inlines = [AudioInline, ImageInline, DocumentInline, PadmaVideoInline] + inlines = [AudioInline, ImageInline, DocumentInline] save_on_top = True list_display = ('__unicode__', 'presenter', 'session',) list_filter = ['session'] @@ -64,6 +64,7 @@ class ProjectAdmin(admin.ModelAdmin): save_on_top = True class SessionAdmin(admin.ModelAdmin): + inlines = [PadmaVideoInline] search_fields = ('title', 'intro',) list_filter = ['day'] list_display = ('__unicode__',) @@ -105,7 +106,7 @@ admin.site.register(Meeting, MeetingAdmin) admin.site.register(Audio, AudioAdmin) admin.site.register(Video, VideoAdmin) admin.site.register(Image, ImageAdmin) -admin.site.register(PadmaVideo, PadmaVideoAdmin) +#admin.site.register(PadmaVideo, PadmaVideoAdmin) admin.site.register(Document, DocumentAdmin) admin.site.register(DocumentSubject) admin.site.register(Project, ProjectAdmin) diff --git a/itf/festival/models.py b/itf/festival/models.py index 10d3c18..c22cf26 100755 --- a/itf/festival/models.py +++ b/itf/festival/models.py @@ -3,6 +3,8 @@ import datetime import time from ckeditor.fields import RichTextField from app.models import ItfModel +from padmavideos.models import PadmaVideo +from django.contrib.contenttypes import generic class Comment(models.Model): name = models.CharField(max_length=255) @@ -149,6 +151,7 @@ class Session(models.Model): intro = models.TextField(blank=True, null=True) day = models.ForeignKey('MeetingDay') session_no = models.IntegerField(blank=True, null=True) + videos = generic.GenericRelation(PadmaVideo) def __unicode__(self): return "%s - %s" % (self.day.meeting.title, self.title) # name of meeting - name of session @@ -235,13 +238,14 @@ class Video(models.Model): def __unicode__(self): return self.title - +''' class PadmaVideo(models.Model): padma_id = models.CharField(max_length=50) talk = models.ForeignKey('Talk') def __unicode__(self): return self.padma_id +''' class Image(models.Model): title = models.CharField(max_length=255) diff --git a/itf/pages/search_indexes.py b/itf/pages/search_indexes.py new file mode 100755 index 0000000..d0d2f23 --- /dev/null +++ b/itf/pages/search_indexes.py @@ -0,0 +1,12 @@ +from haystack.indexes import * +from haystack import site +from models import Page + + +class PageIndex(SearchIndex): + text = CharField(document=True, use_template=True) + title = CharField(model_attr='title') + + +site.register(Page, PageIndex) + diff --git a/itf/settings.py b/itf/settings.py index 6efea3c..427c921 100755 --- a/itf/settings.py +++ b/itf/settings.py @@ -177,6 +177,7 @@ INSTALLED_APPS = ( 'pages', 'tagging', 'app', + 'padmavideos', 'api', # 'boxes', 'frontpage', diff --git a/itf/templates/modules/festival/meeting.html b/itf/templates/modules/festival/meeting.html index ff2dde2..9331c1d 100755 --- a/itf/templates/modules/festival/meeting.html +++ b/itf/templates/modules/festival/meeting.html @@ -70,6 +70,13 @@
{{ s.intro|markdown }}
+ {% ifnotequal s.videos.all|length 0 %} +
+ {% for v in s.videos.all %} + {{ v.embed_code|safe }} + {% endfor %} +
+ {% endifnotequal %} {% ifnotequal s.talks|length 0 %}