Commit f204be4e authored by fred's avatar fred

display tags in episode view

parent 5dc43c16
......@@ -116,6 +116,20 @@ from haystack.views import search_view_factory, FacetedSearchView
from haystack.forms import FacetedSearchForm, SearchForm
class GlobalSearchForm(FacetedSearchForm):
def no_query_found(self):
sqs = super(GlobalSearchForm, self).no_query_found()
if self.selected_facets:
sqs = self.searchqueryset.all()
for facet in self.selected_facets:
if ":" not in facet:
continue
field, value = facet.split(":", 1)
if value:
sqs = sqs.narrow(u'%s:"%s"' % (field, sqs.query.clean(value)))
return sqs
class SearchView(FacetedSearchView):
def extra_context(self):
context = super(SearchView, self).extra_context()
......@@ -131,7 +145,7 @@ class SearchView(FacetedSearchView):
sqs = SearchQuerySet().models(Emission, Episode, NewsItem).facet('categories').facet('tags')
view = search_view_factory(SearchView,
form_class=FacetedSearchForm,
form_class=GlobalSearchForm,
searchqueryset=sqs)
......
......@@ -41,10 +41,10 @@
{% if episode.redif %}<dt>Redifusion</dt><dd>{{ redif }}</dd>{% endif %}
</dl>
{% endif %}
{% if episode.tagList %}
{% if episode.tags.all %}
<ul class="custom inline">
{% for tag in episode.tagList %}
<li><button class="tag">{{ tag }}</button></li>
{% for tag in episode.tags.all %}
<li><a class="tag" href="{% url 'search' %}?&selected_facets=tags_exact:{{tag.slug}}">{{ tag }}</a></li>
{% endfor %}
</ul>
{% endif %}
......
......@@ -8,7 +8,7 @@
<form method="get" action="." class="big center" id="search-form">
{{ form.as_table }}<button class="icon-search"></button>
</form>
{% if query %}
{% if query or selected_tags %}
<nav>
{% if facets.fields.categories %}
<ul class="custom padded">
......@@ -52,7 +52,7 @@
{% block main %}
{% if query %}
{% if query or selected_tags %}
<div class="wrapper">
<div class="marged">
{% if not page.object_list %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment