kopia lustrzana https://github.com/wagtail/wagtail
Removed document search
rodzic
22ddc66776
commit
0805922e4a
|
@ -6,7 +6,6 @@ urlpatterns = patterns('wagtail.wagtaildocs.views',
|
|||
url(r'^add/$', 'documents.add', name='wagtaildocs_add_document'),
|
||||
url(r'^edit/(\d+)/$', 'documents.edit', name='wagtaildocs_edit_document'),
|
||||
url(r'^delete/(\d+)/$', 'documents.delete', name='wagtaildocs_delete_document'),
|
||||
url(r'^search/$', 'documents.search', name='wagtaildocs_search'),
|
||||
|
||||
url(r'^chooser/$', 'chooser.chooser', name='wagtaildocs_chooser'),
|
||||
url(r'^chooser/(\d+)/$', 'chooser.document_chosen', name='wagtaildocs_document_chosen'),
|
||||
|
|
|
@ -140,36 +140,4 @@ def delete(request, document_id):
|
|||
|
||||
return render(request, "wagtaildocs/documents/confirm_delete.html", {
|
||||
'document': doc,
|
||||
})
|
||||
|
||||
|
||||
@permission_required('wagtaildocs.add_document')
|
||||
def search(request):
|
||||
documents = []
|
||||
q = None
|
||||
is_searching = False
|
||||
|
||||
if 'q' in request.GET:
|
||||
form = SearchForm(request.GET)
|
||||
if form.is_valid():
|
||||
q = form.cleaned_data['q']
|
||||
|
||||
is_searching = True
|
||||
documents = Document.search(q, results_per_page=20, prefetch_tags=True)
|
||||
else:
|
||||
form = SearchForm()
|
||||
|
||||
if request.is_ajax():
|
||||
return render(request, "wagtaildocs/documents/results.html", {
|
||||
'documents': documents,
|
||||
'is_searching': is_searching,
|
||||
'search_query': q
|
||||
})
|
||||
else:
|
||||
return render(request, "wagtaildocs/documents/index.html", {
|
||||
'form': form,
|
||||
'documents': documents,
|
||||
'is_searching': True,
|
||||
'search_query': q,
|
||||
'popular_tags': Document.popular_tags(),
|
||||
})
|
||||
})
|
Ładowanie…
Reference in New Issue