search + minor things
This commit is contained in:
parent
e67df25d70
commit
e685ed1a96
|
@ -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):
|
||||
|
|
24
itf/bestpractices/search_indexes.py
Normal file
24
itf/bestpractices/search_indexes.py
Normal file
|
@ -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)
|
|
@ -9,16 +9,6 @@
|
|||
{% endif %}
|
||||
<br /><br />
|
||||
{% endfor %}
|
||||
<span class="orange">Law: </span><span class="itfInfoInfo">{{ law }}</span>
|
||||
{% if law_image %}
|
||||
{% thumbnail law_image "164x114" crop="center" as im %}
|
||||
<img class="itfInfoImg" src="{{ im.url }}" />
|
||||
{% endthumbnail %}
|
||||
{% endif %}
|
||||
<br /><br />
|
||||
<span class="orange">Relevance to Theatre: </span><span class="itfInfoInfo">{{ theatre|linebreaksbr }}</span> <br /><br />
|
||||
<span class="orange">Quick Howto: </span><span class="itfInfoInfo">{{ quick_howto|linebreaksbr }}</span><br /><br />
|
||||
|
||||
<div class="thumbsGallery">
|
||||
{% for img in images %}
|
||||
{% thumbnail img.image "164x114" crop="center" as im %}
|
||||
|
@ -27,6 +17,22 @@
|
|||
{% endfor %}
|
||||
</div>
|
||||
|
||||
|
||||
<span class="orange">Law: </span><span class="itfInfoInfo">{{ law }}</span>
|
||||
{% if law_image %}
|
||||
{% thumbnail law_image "164x114" crop="center" as im %}
|
||||
<img class="itfInfoImg" src="{{ im.url }}" />
|
||||
{% endthumbnail %}
|
||||
{% endif %}
|
||||
<br /><br />
|
||||
{% if theatre %}
|
||||
<span class="orange">Spotlight on Theatre: </span><span class="itfInfoInfo">{{ theatre|linebreaksbr }}</span> <br /><br />
|
||||
{% endif %}
|
||||
{% if quick_howto %}
|
||||
<span class="orange">Quick Howto: </span><span class="itfInfoInfo">{{ quick_howto|linebreaksbr }}</span><br /><br />
|
||||
{% endif %}
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
|
|
@ -29,9 +29,9 @@
|
|||
</div>
|
||||
|
||||
<div id="leftColumn">
|
||||
|
||||
<h3 id="topText">{{ title }}</h3>
|
||||
|
||||
{% load itftags %}
|
||||
<h3 id="topText">{{ title|format_title|safe }}</h3>
|
||||
|
||||
<div id="searchInnerDiv">
|
||||
<img src="/static/images/noel/search-inner.png" width="22" height="18" alt="search" class="searchInner">
|
||||
<!--
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
{{ object.title }}
|
||||
{{ object.story }}
|
||||
{{ object.guideline }}
|
||||
{{ object.law }}
|
||||
{{ object.theatre }}
|
||||
{{ object.quick_howto }}
|
||||
|
||||
|
||||
|
39
itf/templates/search/search.html
Normal file
39
itf/templates/search/search.html
Normal file
|
@ -0,0 +1,39 @@
|
|||
{% extends 'noel/base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<h2>Search</h2>
|
||||
|
||||
<form method="get" action=".">
|
||||
<table>
|
||||
{{ form.as_table }}
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>
|
||||
<input type="submit" value="Search">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
{% if query %}
|
||||
<h3>Results</h3>
|
||||
|
||||
{% for result in page.object_list %}
|
||||
<p>
|
||||
<a href="{{ result.object.get_absolute_url }}">{{ result.object.title }}</a>
|
||||
</p>
|
||||
{% empty %}
|
||||
<p>No results found.</p>
|
||||
{% endfor %}
|
||||
|
||||
{% if page.has_previous or page.has_next %}
|
||||
<div>
|
||||
{% if page.has_previous %}<a href="?q={{ query }}&page={{ page.previous_page_number }}">{% endif %}« Previous{% if page.has_previous %}</a>{% endif %}
|
||||
|
|
||||
{% if page.has_next %}<a href="?q={{ query }}&page={{ page.next_page_number }}">{% endif %}Next »{% if page.has_next %}</a>{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{# Show some example queries to run, maybe query syntax, something else? #}
|
||||
{% endif %}
|
||||
</form>
|
||||
{% endblock %}
|
|
@ -36,7 +36,8 @@ urlpatterns = patterns('',
|
|||
# (r'profile', 'itfcore.views.edit_profile'),
|
||||
(r'i/', include('itfcore.urls')),
|
||||
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
|
||||
|
||||
(r'^search/', include('haystack.urls')),
|
||||
|
||||
# (r'^mockup/', 'itfcore.views.mockup'),
|
||||
# (r'x0news/', 'itfcore.views.allnews'),
|
||||
# (r'x0disc/', 'itfcore.views.disc'),
|
||||
|
|
Loading…
Reference in New Issue
Block a user