def doc_search(request): query = request.GET.get('query', '') result = documentation.search(query) if len([item for exact, item in result if exact]) <= 1: for exact, item in result: if exact or len(result) == 1: if isinstance(item, DocPart): return doc_part(request, item.slug, ajax=True) elif isinstance(item, DocChapter): return doc_chapter(request, item.part.slug, item.slug, ajax=True) else: return doc_section(request, item.chapter.part.slug, item.chapter.slug, item.slug, ajax=True) result = [item for exact, item in result] return render_doc(request, 'search.html', { 'title': "Search documentation", 'result': result, }, ajax=True)
def doc_search(request): query = request.GET.get('query', '') result = documentation.search(query) if len([item for exact, item in result if exact]) <= 1: for exact, item in result: if exact or len(result) == 1: if isinstance(item, DocPart): return doc_part(request, item.slug, ajax=True) elif isinstance(item, DocChapter): return doc_chapter(request, item.part.slug, item.slug, ajax=True) else: return doc_section(request, item.chapter.part.slug, item.chapter.slug, item.slug, ajax=True) result = [item for exact, item in result] return render_doc(request, 'search.html', { 'title': u"Search documentation", 'result': result, }, ajax=True)