From f43ece3b40bd81439c91c23d7907a10f67bb6445 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Thu, 13 Jun 2019 13:33:29 +0200 Subject: [PATCH] Import serve_docs from Corporate Use the serve_docs from Corporate as a HACK and do nothing extra if it fails for any reason --- readthedocs/core/views/serve.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/readthedocs/core/views/serve.py b/readthedocs/core/views/serve.py index b2b93ad8293..73029b770c0 100644 --- a/readthedocs/core/views/serve.py +++ b/readthedocs/core/views/serve.py @@ -115,14 +115,21 @@ def redirect_project_slug(request, project, subproject): # pylint: disable=unus # ``subproject`` is a single-version, we don't have to redirect but to serve # the index file instead. if subproject and subproject.single_version: - # TODO: find a way to import ``serve_docs`` from corporate - return serve_docs(request, project, project.slug, subproject, subproject.slug) + try: + # HACK: this only affects corporate site and won't be hit on the + # community. This can be removed once the middleware incorporates + # more data or redirects happen outside this application + # See: https://github.com/rtfd/readthedocs.org/pull/5690 + from readthedocsinc.core.views import serve_docs as corporate_serve_docs + return corporate_serve_docs(request, project, project.slug, subproject, subproject.slug) + except Exception: + pass return HttpResponseRedirect( resolve( subproject or project, query_params=urlparse_result.query, - ) + ), )