Skip to content

Commit

Permalink
Copy hack to keep facet selections when changing relevancy
Browse files Browse the repository at this point in the history
SearchView just passes request data through to keep facet selections.
It's not a security risk, but still a nasty hack. But as this PR to
improve search has already grown to seach epic proportions, we just
imitate the same thing here.
  • Loading branch information
maiksprenger committed Aug 22, 2014
1 parent c25f5c7 commit 4938665
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 0 additions & 1 deletion oscar/apps/search/facets.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.conf import settings
from django.utils.six.moves import map
from purl import URL
from haystack.query import SearchQuerySet

Expand Down
6 changes: 6 additions & 0 deletions oscar/apps/search/search_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class SearchHandler(object):

def __init__(self, request_data, full_path):
self.full_path = full_path
self.request_data = request_data

# Triggers the search.
search_queryset = self.get_search_queryset()
Expand Down Expand Up @@ -196,6 +197,11 @@ def get_search_context_data(self, context_object_name=None):
context = {
'facet_data': facet_data,
'has_facets': has_facets,
# This is a serious code smell; we just pass through the selected
# facets data to the view again, and the template adds those
# as fields to the form. This hack ensures that facets stay
# selected when changing relevancy.
'selected_facets': self.request_data.getlist('selected_facets'),
'form': self.search_form,
'paginator': self.paginator,
'page_obj': self.page,
Expand Down

0 comments on commit 4938665

Please sign in to comment.