Browse files

Removing urls.py as app.py is currently used instead

Switching to using the module loader to allow for easier overriding
SearchQuerySet.facet returns a clone of itself so we have to assign is back to itself whenever we add a new facet
  • Loading branch information...
1 parent 3d0fead commit 163b337c8b181ae97a50e0d03aef025e32ce3592 Jonathan Moss committed Jul 16, 2012
Showing with 6 additions and 25 deletions.
  1. +6 −5 oscar/apps/search/app.py
  2. +0 −20 oscar/apps/search/urls.py
View
11 oscar/apps/search/app.py
@@ -3,10 +3,11 @@
from haystack.query import SearchQuerySet
from oscar.core.application import Application
-from oscar.apps.search.views import SuggestionsView, MultiFacetedSearchView
-from oscar.apps.search.search_indexes import ProductIndex
-from oscar.apps.search.forms import MultiFacetedSearchForm
+from oscar.core.loading import import_module
+import_module('search.views', ['SuggestionsView', 'MultiFacetedSearchView'], locals())
+import_module('search.search_indexes', ['ProductIndex'], locals())
+import_module('search.forms', ['MultiFacetedSearchForm'], locals())
class SearchApplication(Application):
name = 'search'
@@ -19,7 +20,7 @@ def get_urls(self):
for field_name, field in ProductIndex.fields.items():
if field.faceted is True:
# Ensure we facet the results set by the defined facetable fields
- sqs.facet(field_name)
+ sqs = sqs.facet(field_name)
urlpatterns = patterns('',
url(r'^suggest/$', self.suggestions_view.as_view(), name='suggest'),
@@ -29,4 +30,4 @@ def get_urls(self):
return self.post_process_urls(urlpatterns)
-application = SearchApplication()
+application = SearchApplication()
View
20 oscar/apps/search/urls.py
@@ -1,20 +0,0 @@
-from django.conf.urls.defaults import *
-from haystack.query import SearchQuerySet
-
-from oscar.core.loading import import_module
-import_module('search.views', ['Suggestions', 'MultiFacetedSearchView'], locals())
-import_module('search.forms', ['MultiFacetedSearchForm'], locals())
-import_module('search.search_indexes', ['ProductIndex'], locals())
-
-
-sqs = SearchQuerySet()
-for field_name, field in ProductIndex.fields.items():
- if field.faceted is True:
- # Ensure we facet the results set by the defined facetable fields
- sqs.facet(field_name)
-
-urlpatterns = patterns('search.apps.views',
- url(r'^suggest/$', Suggestions.as_view(), name='oscar-search-suggest'),
- url(r'^$', MultiFacetedSearchView(form_class=MultiFacetedSearchForm,
- searchqueryset=sqs), name='oscar-search'),
-)

0 comments on commit 163b337

Please sign in to comment.