diff --git a/apps/search/views.py b/apps/search/views.py index 9a3341db66..af49ae21a2 100644 --- a/apps/search/views.py +++ b/apps/search/views.py @@ -368,15 +368,17 @@ def ajax_search_suggestions(request): }) # Categories. - cats = (Category.objects - .filter(Q(application=request.APP.id) | - Q(type=amo.ADDON_SEARCH))) - if cat == 'personas': - cats = cats.filter(type=amo.ADDON_PERSONA) - elif cat == 'apps': + cats = Category.objects + if cat == 'apps': cats = cats.filter(type=amo.ADDON_WEBAPP) else: - cats = cats.exclude(type__in=[amo.ADDON_PERSONA, amo.ADDON_WEBAPP]) + cats = cats.filter(Q(application=request.APP.id) | + Q(type=amo.ADDON_SEARCH)) + if cat == 'personas': + cats = cats.filter(type=amo.ADDON_PERSONA) + else: + cats = cats.exclude(type__in=[amo.ADDON_PERSONA, + amo.ADDON_WEBAPP]) for c in cats: if not c.name: diff --git a/media/js/impala/suggestions.js b/media/js/impala/suggestions.js index 7ae043f19b..43a8fe8212 100644 --- a/media/js/impala/suggestions.js +++ b/media/js/impala/suggestions.js @@ -18,17 +18,16 @@ $.fn.highlightTerm = function(val) { }; -$.fn.searchSuggestions = function(results) { +$.fn.searchSuggestions = function($results) { var $self = this, - $form = $self.closest('form'), - $results = results; + $form = $self.closest('form'); if (!$results.length) { return; } // Some base elements that we don't want to keep creating on the fly. - var cat = $form.find('input[name=cat]').val(), + var cat = $results.attr('data-cat'), msg; if (cat == 'personas') { msg = gettext('Search personas for {0}'); @@ -147,8 +146,8 @@ $.fn.searchSuggestions = function(results) { ); $.ajaxCache({ - url: $results.attr('data-src'), - data: $form.serialize(), + url: $form.serialize() + '&cat=' + cat, + data: fields, newItems: function(formdata, items) { var eventName; if (items !== undefined) { diff --git a/templates/impala/search.html b/templates/impala/search.html index a6f4b858bd..98b90cd064 100644 --- a/templates/impala/search.html +++ b/templates/impala/search.html @@ -19,6 +19,7 @@ src="{{ media('img/zamboni/global/btn-search.png') }}"> {% if search_cat != 'collections' and waffle.switch('search-suggestions') %}
{% endif %} diff --git a/templates/search.html b/templates/search.html index 4dc476c913..0a1caf3b03 100644 --- a/templates/search.html +++ b/templates/search.html @@ -13,6 +13,7 @@ src="{{ media('img/zamboni/global/btn-search.png') }}"> {% if search_cat != 'collections' and waffle.switch('search-suggestions') %} {% endif %}