search stuff

This commit is contained in:
Sanj 2012-03-28 01:58:28 +05:30
parent b038081804
commit 780e39d736
9 changed files with 60 additions and 10 deletions

12
itf/emailer/search_indexes.py Executable file
View File

@ -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)

View File

@ -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)

View File

@ -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)

12
itf/pages/search_indexes.py Executable file
View File

@ -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)

View File

@ -177,6 +177,7 @@ INSTALLED_APPS = (
'pages',
'tagging',
'app',
'padmavideos',
'api',
# 'boxes',
'frontpage',

View File

@ -70,6 +70,13 @@
<div class="sessionIntro">
{{ s.intro|markdown }}
</div>
{% ifnotequal s.videos.all|length 0 %}
<div class="padmaVideos">
{% for v in s.videos.all %}
{{ v.embed_code|safe }}
{% endfor %}
</div>
{% endifnotequal %}
{% ifnotequal s.talks|length 0 %}
<ul class="talks">
{% for talk in s.talks %}

View File

@ -0,0 +1,8 @@
{{ object.title }}
{% for article in object.emailerarticle_set.all %}
{{ article.title }}
{{ article.subtitle }}
{{ article.author }}
{{ article.author_bio }}
{{ article.text }}
{% endfor %}

View File

@ -0,0 +1,2 @@
{{ object.title }}
{{ object.text }}

View File

@ -1,5 +1,6 @@
{% extends 'noel/base.html' %}
{% load highlight %}
{% load markup %}
{% block extra_head %}
<link rel="stylesheet" href="/static/css/noel/inner.css" type="text/css" />
<script type="text/javascript" src="/static/js/search.js"></script>
@ -16,6 +17,7 @@
<div id="searchContent">
<!-- <h2>Search:</h2> -->
<!--
<form method="get" action="." id="searchItf">
<table>
{{ form.as_table }}
@ -26,13 +28,15 @@
</td>
</tr>
</table>
-->
{% if query %}
<h2>YOUR RESULTS:</h2>
{% for result in page.object_list %}
<p>
<a href="{{ result.object.get_absolute_url }}&amp;search={{ query }}">{{ result.object.title }}</a>
<a href="{{ result.object.get_absolute_url }}&amp;search={{ query }}">{{ result.object.title }}</a> <br />
{{ result.text|truncatewords:60|markdown|safe }}
</p>
{% empty %}
<p class="noResults">No results found.</p>
@ -41,7 +45,6 @@
{% else %}
{# Show some example queries to run, maybe query syntax, something else? #}
{% endif %}
</form>
{% if page.has_previous or page.has_next %}
<div id="prevNext">