From 0dbbe9f6f0a5aac45df5311bfef3d7b90cd8c50c Mon Sep 17 00:00:00 2001 From: afilsaime Date: Wed, 6 May 2015 15:59:24 +0200 Subject: [PATCH] fix filter display when no facet found --- telemeta/templates/search/filters.html | 31 ++++++++++++++++++++++++++ telemeta/views/haystack_search.py | 11 ++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/telemeta/templates/search/filters.html b/telemeta/templates/search/filters.html index d47b5fc7..ecb4eb1f 100644 --- a/telemeta/templates/search/filters.html +++ b/telemeta/templates/search/filters.html @@ -7,6 +7,12 @@ {% for item_status in facets.fields.item_status %} {{ item_status.0 }} {{ item_status.1 }} {% endfor %} + {% if Published_count == 0 %} + Published 0 + {% endif %} + {% if Unpublished_count == 0 %} + Unpublished 0 + {% endif %} {% else %} Item Status None @@ -69,8 +75,15 @@ {{ media_type.0 }} {{ media_type.1 }} {% endifequal %} {% endfor %} + {% if Video_count == 0 %} + Video 0 + {% endif %} + {% if Audio_count == 0 %} + Audio 0 + {% endif %} {% endif %} + {% if facets.fields.recording_context %} Recording Context @@ -85,6 +98,15 @@ {{ recording_context.0 }} {{ recording_context.1 }} {% endifequal %} {% endfor %} + {% if Terrain_count == 0 %} + Terrain 0 + {% endif %} + {% if Radio_count == 0 %} + Radio 0 + {% endif %} + {% if Studio_count == 0 %} + Studio 0 + {% endif %} {% endif %} @@ -101,6 +123,15 @@ {{ physical_format.0 }} {{ physical_format.1 }} {% endifequal %} {% endfor %} + {% if CDR_count == 0 %} + CDR 0 + {% endif %} + {% if Disque_count == 0 %} + Disque 0 + {% endif %} + {% if Cylindre_count == 0 %} + Cylindre 0 + {% endif %} {% endif %} diff --git a/telemeta/views/haystack_search.py b/telemeta/views/haystack_search.py index 8d138d66..c7846502 100644 --- a/telemeta/views/haystack_search.py +++ b/telemeta/views/haystack_search.py @@ -52,9 +52,18 @@ class HaystackSearch(FacetedSearchView): else: viewable_total = viewable_total + viewable[1] + extra['Published_count']=self.get_results().narrow('item_status:Published').count() + extra['Unpublished_count']=self.get_results().narrow('item_status:Unpublished').count() extra['viewable_count'] = self.get_results().narrow('item_acces:full OR item_acces:mixed').narrow('digitized:T').count() extra['digitized_count'] = self.get_results().narrow('digitized:T').count() - + extra['CDR_count']=self.get_results().narrow('physical_format:CDR').count() + extra['Disque_count']=self.get_results().narrow('physical_format:Disque').count() + extra['Cylindre_count']=self.get_results().narrow('physical_format:Cylindre').count() + extra['Studio_count']=self.get_results().narrow('recording_context:Studio').count() + extra['Terrain_count']=self.get_results().narrow('recording_context:Terrain').count() + extra['Radio_count']=self.get_results().narrow('recording_context:Radio').count() + extra['Video_count']=self.get_results().narrow('media_type:Video').count() + extra['Audio_count']=self.get_results().narrow('media_type:Audio').count() if self.type == 'collection': extra['type'] = 'collection' else: -- 2.39.5