Added backwards compatibility to new search view

pull/89/head
Karl Hobley 2014-02-24 11:01:59 +00:00
rodzic 03019b9640
commit cc42de0cd4
2 zmienionych plików z 24 dodań i 1 usunięć

Wyświetl plik

@ -0,0 +1,8 @@
from django.conf.urls import patterns, url
urlpatterns = patterns(
'wagtail.wagtailsearch.views',
url(r'^$', 'search', name='wagtailsearch_search'),
url(r'^suggest/$', 'search', {'use_json': True}, name='wagtailsearch_suggest'),
)

Wyświetl plik

@ -11,7 +11,7 @@ from wagtail.wagtailsearch.models import Query
def search(
request,
template='wagtailsearch/search_results.html',
template=None,
template_ajax=None,
results_per_page=10,
use_json=False,
@ -21,6 +21,21 @@ def search(
extra_filters={},
path=None,
):
# Get default templates
if template is None:
if hasattr(settings, 'WAGTAILSEARCH_RESULTS_TEMPLATE'):
template = settings.WAGTAILSEARCH_RESULTS_TEMPLATE
else:
template = 'wagtailsearch/search_results.html'
if template_ajax is None:
if hasattr(settings, 'WAGTAILSEARCH_RESULTS_TEMPLATE_AJAX'):
template_ajax = settings.WAGTAILSEARCH_RESULTS_TEMPLATE_AJAX
else:
template_ajax = template
# Get query string and page from GET paramters
query_string = request.GET.get('q', '')
page = request.GET.get('p', 1)