Commit 3ef012f9 authored by fred's avatar fred

search: uniform search filters

parent 2a96656f
......@@ -142,6 +142,11 @@ class SearchView(FacetedSearchView):
context['selected_tags'] = [
x.split(':', 1)[1] for x in self.request.GET.getlist('selected_facets')
if x.startswith('tags_exact')]
context['facets']['fields']['categories'] = [x for x in
context['facets']['fields']['categories'] if x[1] > 0]
context['facets']['fields']['categories'].sort()
context['facets']['fields']['tags'] = [x for x in
context['facets']['fields']['tags'] if x[1] > 0]
return context
sqs = SearchQuerySet().models(Emission, Episode, NewsItem).facet('categories').facet('tags')
......@@ -180,7 +185,11 @@ class ListenArchivesView(FacetedSearchView):
context['selected_tags'] = [
x.split(':', 1)[1] for x in self.request.GET.getlist('selected_facets')
if x.startswith('tags_exact')]
context['facets']['fields']['categories'] = [x for x in
context['facets']['fields']['categories'] if x[1] > 0]
context['facets']['fields']['categories'].sort()
context['facets']['fields']['tags'] = [x for x in
context['facets']['fields']['tags'] if x[1] > 0]
return context
listenArchives = search_view_factory(ListenArchivesView)
......@@ -214,6 +223,11 @@ class NewsArchivesView(FacetedSearchView):
context['selected_tags'] = [
x.split(':', 1)[1] for x in self.request.GET.getlist('selected_facets')
if x.startswith('tags_exact')]
context['facets']['fields']['news_categories'] = [x for x in
context['facets']['fields']['news_categories'] if x[1] > 0]
context['facets']['fields']['news_categories'].sort()
context['facets']['fields']['tags'] = [x for x in
context['facets']['fields']['tags'] if x[1] > 0]
return context
newsArchives = search_view_factory(NewsArchivesView)
......@@ -1126,9 +1126,11 @@ ul.newsSpecial{
font-style: italic;
}
.newsFilters .count-0{
display:none !important;
.search-filters {
text-align: justify;
}
/****************************************************/
/**** GRILLE ****/
/****************************************************/
......
......@@ -11,17 +11,18 @@ pri, ei viris quaestio concludaturque qui, cu copiosae senserit quo. Cu dictas
officiis has, hinc libris aliquam pro te.
</p>
<div class="search-filters">
{% if facets.fields.categories %}
<nav>
<ul class="custom padded">
<li><span class="mainLabel">Genre :</span></li>
{% for category in facets.fields.categories %} <li>
{% if category.0 in selected_categories %}
<a class="check icon-check count-{{ category.1 }}" href="{{ request.get_full_path|remove_category_facet:category.0 }}">
<a class="check icon-check" href="{{ request.get_full_path|remove_category_facet:category.0 }}">
{{ category.0 }} | {{ category.1 }}
</a>
{% else %}
<a class="check icon-check-empty count-{{ category.1 }}" href="{{ request.get_full_path|append_category_facet:category.0 }}">{{ category.0 }} | {{ category.1 }}</a></span>
<a class="check icon-check-empty" href="{{ request.get_full_path|append_category_facet:category.0 }}">{{ category.0 }} | {{ category.1 }}</a></span>
{% endif %}
</li>
{% endfor %}
......@@ -32,21 +33,22 @@ officiis has, hinc libris aliquam pro te.
{% if facets.fields.tags %}
<nav>
<ul class="tag-facets custom padded">
<li><span class="mainLabel">Mots clés :</span></li>
<li><span class="mainLabel">Mots-clés :</span></li>
{% for tag in facets.fields.tags|slice:":20" %} {# Provide only the top 20 tags #}
<li>
{% if tag.0 in selected_tags %}
<a class="check icon-check count-{{ tag.1 }}" href="{{ request.get_full_path|remove_tag_facet:tag.0 }}">
<a class="check icon-check" href="{{ request.get_full_path|remove_tag_facet:tag.0 }}">
{{ tag.0 }} <span class="smooth">| {{ tag.1 }}</span>
</a>
{% else %}
<a class="check icon-check-empty count-{{ tag.1 }}" href="{{ request.get_full_path|append_tag_facet:tag.0 }}">{{ tag.0 }} <span class="smooth">| {{ tag.1 }}</span></a>
<a class="check icon-check-empty" href="{{ request.get_full_path|append_tag_facet:tag.0 }}">{{ tag.0 }} <span class="smooth">| {{ tag.1 }}</span></a>
{% endif %}
</li>
{% endfor %}
</ul>
</nav>
{% endif %}
</div> <!-- .search-filters -->
{% endblock %}
......
......@@ -3,19 +3,18 @@
{% load paniktags %}
{% block title %}Actus - Archives{% endblock %}
{% block nav %}
{% news_nav with klass="archives" %}
<div class="search-filters">
{% if facets.fields.news_categories %}
<nav>
<ul class="custom padded">
<li><span class="mainLabel">Catégorie :</span></li>
{% for category in facets.fields.news_categories %} <li>
{% if category.0 in selected_news_categories %}
<a class="check icon-check count-{{ category.1 }}" href="{{ request.get_full_path|remove_news_category_facet:category.0 }}">
<a class="check icon-check" href="{{ request.get_full_path|remove_news_category_facet:category.0 }}">
{{ category.0 }} <span class="smooth">| {{ category.1 }}</span>
</a>
{% else %}
<a class="check icon-check-empty count-{{ category.1 }}" href="{{ request.get_full_path|append_news_category_facet:category.0 }}">{{ category.0 }} <span class="smooth">| {{ category.1 }}</span></a>
<a class="check icon-check-empty" href="{{ request.get_full_path|append_news_category_facet:category.0 }}">{{ category.0 }} <span class="smooth">| {{ category.1 }}</span></a>
{% endif %}
</li>
{% endfor %}
......@@ -26,23 +25,22 @@
{% if facets.fields.tags %}
<nav>
<ul class="tag-facets custom padded">
<li><span class="mainLabel">Mots clés :</span></li>
<li><span class="mainLabel">Mots-clés :</span></li>
{% for tag in facets.fields.tags|slice:":20" %} {# Provide only the top 20 tags #}
<li>
{% if tag.0 in selected_tags %}
<a class="check icon-check count-{{ tag.1 }}" href="{{ request.get_full_path|remove_tag_facet:tag.0 }}">
<a class="check icon-check" href="{{ request.get_full_path|remove_tag_facet:tag.0 }}">
{{ tag.0 }} <span class="smooth">| {{ tag.1 }}</span>
</a>
{% else %}
<a class="check icon-check-empty count-{{ tag.1 }}" href="{{ request.get_full_path|append_tag_facet:tag.0 }}">{{ tag.0 }} <span class="smooth">| {{ tag.1 }}</span></a>
<a class="check icon-check-empty" href="{{ request.get_full_path|append_tag_facet:tag.0 }}">{{ tag.0 }} <span class="smooth">| {{ tag.1 }}</span></a>
{% endif %}
</li>
{% endfor %}
</ul>
</nav>
{% endif %}
</div>
{% endblock %}
{% block main %}
......
......@@ -14,21 +14,21 @@
</div>
</div>
<div class="wrapper">
<div class="newsFilters">
<div class="search-filters">
{% if query or selected_tags %}
<nav class="">
{% if facets.fields.categories %}
<ul class="custom padded">
<li><span class="mainLabel">Genre:</span></li>
<li><span class="mainLabel">Genre :</span></li>
{# Provide only the top 5 categories #}
{% for category in facets.fields.categories|slice:":5" %}
<li>
{% if category.0 in selected_categories %}
<a class="check icon-check count-{{ category.1 }}" href="{{ request.get_full_path|remove_category_facet:category.0 }}">
<a class="check icon-check" href="{{ request.get_full_path|remove_category_facet:category.0 }}">
{{ category.0 }} <span class="smooth">| {{ category.1 }}</span>
</a>
{% else %}
<a class="check icon-check-empty count-{{ category.1 }}" href="{{ request.get_full_path|append_category_facet:category.0 }}"
<a class="check icon-check-empty" href="{{ request.get_full_path|append_category_facet:category.0 }}"
>{{ category.0 }} <span class="smooth">| {{ category.1 }}</span></a></span>
{% endif %}
</li>
......@@ -39,16 +39,16 @@
<nav>
{% if facets.fields.tags %}
<ul class="tag-facets custom padded">
<li><span class="mainLabel">Mots clés:</span></li>
<li><span class="mainLabel">Mots-clés :</span></li>
{# Provide only the top 5 tags #}
{% for tag in facets.fields.tags|slice:":20" %}
<li>
{% if tag.0 in selected_tags %}
<a class="check icon-check count-{{ tag.1 }}" href="{{ request.get_full_path|remove_tag_facet:tag.0 }}">
<a class="check icon-check" href="{{ request.get_full_path|remove_tag_facet:tag.0 }}">
{{ tag.0 }} <span class="smooth">| {{ tag.1 }}</span>
</a>
{% else %}
<a class="check icon-check-empty count-{{ tag.1 }}" href="{{ request.get_full_path|append_tag_facet:tag.0 }}">{{ tag.0 }} <span class="smooth">| {{ tag.1 }}</span></a>
<a class="check icon-check-empty" href="{{ request.get_full_path|append_tag_facet:tag.0 }}">{{ tag.0 }} <span class="smooth">| {{ tag.1 }}</span></a>
{% endif %}
</li>
{% endfor %}
......
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