Commit 01347dfc authored by fred's avatar fred

search: harden

parent 7343d670
......@@ -142,11 +142,13 @@ 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]
if 'categories' in context['facets'].get('fields', []):
context['facets']['fields']['categories'] = [x for x in
context['facets']['fields']['categories'] if x[1] > 0]
context['facets']['fields']['categories'].sort()
if 'tags' in context['facets'].get('fields', []):
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')
......@@ -185,11 +187,13 @@ 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]
if 'categories' in context['facets'].get('fields', []):
context['facets']['fields']['categories'] = [x for x in
context['facets']['fields']['categories'] if x[1] > 0]
context['facets']['fields']['categories'].sort()
if 'tags' in context['facets'].get('fields', []):
context['facets']['fields']['tags'] = [x for x in
context['facets']['fields']['tags'] if x[1] > 0]
return context
listenArchives = search_view_factory(ListenArchivesView)
......@@ -223,11 +227,13 @@ 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]
if 'news_categories' in context['facets'].get('fields', []):
context['facets']['fields']['news_categories'] = [x for x in
context['facets']['fields']['news_categories'] if x[1] > 0]
context['facets']['fields']['news_categories'].sort()
if 'tags' in context['facets'].get('fields', []):
context['facets']['fields']['tags'] = [x for x in
context['facets']['fields']['tags'] if x[1] > 0]
return context
newsArchives = search_view_factory(NewsArchivesView)
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