From e685ed1a9632fe1e380f19217202987c363b2457 Mon Sep 17 00:00:00 2001 From: Sanj Date: Sat, 8 Oct 2011 06:09:33 +0530 Subject: [PATCH] search + minor things --- itf/bestpractices/models.py | 3 +- itf/bestpractices/search_indexes.py | 24 ++++++++++++ .../modules/bestpractices/bestpractice.html | 26 ++++++++----- itf/templates/noel/insidepage.html | 6 +-- .../bestpractices/bestpractice_text.txt | 9 +++++ itf/templates/search/search.html | 39 +++++++++++++++++++ itf/urls.py | 3 +- 7 files changed, 95 insertions(+), 15 deletions(-) create mode 100644 itf/bestpractices/search_indexes.py create mode 100644 itf/templates/search/indexes/bestpractices/bestpractice_text.txt create mode 100644 itf/templates/search/search.html diff --git a/itf/bestpractices/models.py b/itf/bestpractices/models.py index 467c530..6262cfe 100644 --- a/itf/bestpractices/models.py +++ b/itf/bestpractices/models.py @@ -43,7 +43,8 @@ class BestPractice(ItfModel): 'quick_howto': self.quick_howto, 'category': self.category.name, 'category_id': self.category.id, - 'images': self.get_images() + 'images': self.get_images(), + 'links': BestPracticeLink.objects.filter(bestpractice=self) } def main_image(self): diff --git a/itf/bestpractices/search_indexes.py b/itf/bestpractices/search_indexes.py new file mode 100644 index 0000000..f371314 --- /dev/null +++ b/itf/bestpractices/search_indexes.py @@ -0,0 +1,24 @@ +from haystack.indexes import * +from haystack import site +from models import * + + +class BestPracticeIndex(SearchIndex): + text = CharField(document=True, use_template=True) + title = CharField(model_attr='title') + story = CharField(model_attr='story') + guideline = CharField(model_attr='guideline') + law = CharField(model_attr='law') + theatre = CharField(model_attr='theatre') + quick_howto = CharField(model_attr='quick_howto') +# pub_date = DateTimeField(model_attr='pub_date') + category = CharField(model_attr='category') +# added = DateTimeField(model_attr='added') + + ''' + def index_queryset(self): + """Used when the entire index for model is updated.""" + return Note.objects.filter(pub_date__lte=datetime.datetime.now()) + ''' + +site.register(BestPractice, BestPracticeIndex) diff --git a/itf/templates/modules/bestpractices/bestpractice.html b/itf/templates/modules/bestpractices/bestpractice.html index 21baa11..2389510 100644 --- a/itf/templates/modules/bestpractices/bestpractice.html +++ b/itf/templates/modules/bestpractices/bestpractice.html @@ -9,16 +9,6 @@ {% endif %}

{% endfor %} - Law: {{ law }} - {% if law_image %} - {% thumbnail law_image "164x114" crop="center" as im %} - - {% endthumbnail %} - {% endif %} -

- Relevance to Theatre: {{ theatre|linebreaksbr }}

- Quick Howto: {{ quick_howto|linebreaksbr }}

-
{% for img in images %} {% thumbnail img.image "164x114" crop="center" as im %} @@ -27,6 +17,22 @@ {% endfor %}
+ + Law: {{ law }} + {% if law_image %} + {% thumbnail law_image "164x114" crop="center" as im %} + + {% endthumbnail %} + {% endif %} +

+ {% if theatre %} + Spotlight on Theatre: {{ theatre|linebreaksbr }}

+ {% endif %} + {% if quick_howto %} + Quick Howto: {{ quick_howto|linebreaksbr }}

+ {% endif %} + + diff --git a/itf/templates/noel/insidepage.html b/itf/templates/noel/insidepage.html index c087194..90d7cca 100644 --- a/itf/templates/noel/insidepage.html +++ b/itf/templates/noel/insidepage.html @@ -29,9 +29,9 @@
- -

{{ title }}

- + {% load itftags %} +

{{ title|format_title|safe }}

+
search