@require_GET
@allow_CORS_GET
@process_document_path
@prevent_indexing
def toc(request, document_slug=None, document_locale=None):
 query = {'locale': request.LANGUAGE_CODE, 'current_revision__isnull': False}
 if (document_slug is not None):
  query['slug'] = document_slug
  query['locale'] = document_locale
 elif ('title' in request.GET):
  query['title'] = request.GET['title']
 elif ('slug' in request.GET):
  query['slug'] = request.GET['slug']
 else:
  return HttpResponseBadRequest()
 document = get_object_or_404(Document, **query)
 toc_html = document.get_toc_html()
 if toc_html:
  toc_html = (('<ol>' + toc_html) + '</ol>')
 return HttpResponse(toc_html)

@ require_GET @ allow_CORS_GET @ process_document_path @ prevent_indexing def toc ( request , document_slug = None , document_locale = None ) : query = { 'locale' : request . LANGUAGE_CODE , 'current_revision__isnull' : False } if ( document_slug is not None ) : query [ 'slug' ] = document_slug query [ 'locale' ] = document_locale elif ( 'title' in request . GET ) : query [ 'title' ] = request . GET [ 'title' ] elif ( 'slug' in request . GET ) : query [ 'slug' ] = request . GET [ 'slug' ] else : return HttpResponseBadRequest ( ) document = get_object_or_404 ( Document , ** query ) toc_html = document . get_toc_html ( ) if toc_html : toc_html = ( ( '<ol>' + toc_html ) + '</ol>' ) return HttpResponse ( toc_html )
return a documents table of contents as html .