We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Old version banner uses a version number format present nowhere else
## Details
- Project URL: https://github.com/dfhack/dfhack/
- Build URL: http://dfhack.readthedocs.io/en/v0.40.24-r5/ and http://dfhack.readthedocs.io/en/0.42.06-r1/
- Read the Docs username:  lethosor
## Expected result

The banner on documentation pages for old versions of our project should refer to the newest version using the same version number format present used elsewhere - in this case, "0.43.03-r1"
## Actual result

The banner refers to "0.43.3-post1", which isn't used anywhere else, as far as I can tell.
## Additional Information

It would be great if this banner could use the version numbers that our project uses instead of the ones with "post1" at the end. I realize the scheme we use is a bit unconventional, but it's tied to another project which uses the "0.43.03" format that we don't really have control over.

I made a tentative patch at https://github.com/lethosor/readthedocs.org/commit/7d84130471885905a3f663324af602b7be1f7f64, although I haven't tested it enough to be confident that it'll work for other projects. In particular, I'm not sure in what situations (if any) `slugs` could contain multiple items.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `readthedocs/restapi/views/footer_views.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 """Endpoint to generate footer HTML."""
3 
4 from __future__ import (
5     absolute_import, division, print_function, unicode_literals)
6 
7 import six
8 from django.conf import settings
9 from django.shortcuts import get_object_or_404
10 from django.template import loader as template_loader
11 from rest_framework import decorators, permissions
12 from rest_framework.renderers import JSONRenderer
13 from rest_framework.response import Response
14 from rest_framework_jsonp.renderers import JSONPRenderer
15 
16 from readthedocs.builds.constants import LATEST, TAG
17 from readthedocs.builds.models import Version
18 from readthedocs.projects.models import Project
19 from readthedocs.projects.version_handling import (
20     highest_version, parse_version_failsafe)
21 from readthedocs.restapi.signals import footer_response
22 
23 
24 def get_version_compare_data(project, base_version=None):
25     """
26     Retrieve metadata about the highest version available for this project.
27 
28     :param base_version: We assert whether or not the base_version is also the
29                          highest version in the resulting "is_highest" value.
30     """
31     versions_qs = project.versions.public().filter(active=True)
32 
33     # Take preferences over tags only if the project has at least one tag
34     if versions_qs.filter(type=TAG).exists():
35         versions_qs = versions_qs.filter(type=TAG)
36 
37     highest_version_obj, highest_version_comparable = highest_version(
38         versions_qs)
39     ret_val = {
40         'project': six.text_type(highest_version_obj),
41         'version': six.text_type(highest_version_comparable),
42         'is_highest': True,
43     }
44     if highest_version_obj:
45         ret_val['url'] = highest_version_obj.get_absolute_url()
46         ret_val['slug'] = (highest_version_obj.slug,)
47     if base_version and base_version.slug != LATEST:
48         try:
49             base_version_comparable = parse_version_failsafe(
50                 base_version.verbose_name)
51             if base_version_comparable:
52                 # This is only place where is_highest can get set. All error
53                 # cases will be set to True, for non- standard versions.
54                 ret_val['is_highest'] = (
55                     base_version_comparable >= highest_version_comparable)
56             else:
57                 ret_val['is_highest'] = True
58         except (Version.DoesNotExist, TypeError):
59             ret_val['is_highest'] = True
60     return ret_val
61 
62 
63 @decorators.api_view(['GET'])
64 @decorators.permission_classes((permissions.AllowAny,))
65 @decorators.renderer_classes((JSONRenderer, JSONPRenderer))
66 def footer_html(request):
67     """Render and return footer markup."""
68     # TODO refactor this function
69     # pylint: disable=too-many-locals
70     project_slug = request.GET.get('project', None)
71     version_slug = request.GET.get('version', None)
72     page_slug = request.GET.get('page', None)
73     theme = request.GET.get('theme', False)
74     docroot = request.GET.get('docroot', '')
75     subproject = request.GET.get('subproject', False)
76     source_suffix = request.GET.get('source_suffix', '.rst')
77 
78     # Hack in a fix for missing version slug deploy that went out a while back
79     if version_slug == '':
80         version_slug = LATEST
81 
82     new_theme = (theme == 'sphinx_rtd_theme')
83     using_theme = (theme == 'default')
84     project = get_object_or_404(Project, slug=project_slug)
85     version = get_object_or_404(
86         Version.objects.public(
87             request.user, project=project, only_active=False),
88         slug__iexact=version_slug)
89     main_project = project.main_language_project or project
90 
91     if page_slug and page_slug != 'index':
92         if (main_project.documentation_type == 'sphinx_htmldir' or
93                 main_project.documentation_type == 'mkdocs'):
94             path = page_slug + '/'
95         elif main_project.documentation_type == 'sphinx_singlehtml':
96             path = 'index.html#document-' + page_slug
97         else:
98             path = page_slug + '.html'
99     else:
100         path = ''
101 
102     version_compare_data = get_version_compare_data(project, version)
103 
104     context = {
105         'project': project,
106         'version': version,
107         'path': path,
108         'downloads': version.get_downloads(pretty=True),
109         'current_version': version.verbose_name,
110         'versions': project.ordered_active_versions(user=request.user),
111         'main_project': main_project,
112         'translations': main_project.translations.all(),
113         'current_language': project.language,
114         'using_theme': using_theme,
115         'new_theme': new_theme,
116         'settings': settings,
117         'subproject': subproject,
118         'github_edit_url': version.get_github_url(
119             docroot,
120             page_slug,
121             source_suffix,
122             'edit',
123         ),
124         'github_view_url': version.get_github_url(
125             docroot,
126             page_slug,
127             source_suffix,
128             'view',
129         ),
130         'gitlab_edit_url': version.get_gitlab_url(
131             docroot,
132             page_slug,
133             source_suffix,
134             'edit',
135         ),
136         'gitlab_view_url': version.get_gitlab_url(
137             docroot,
138             page_slug,
139             source_suffix,
140             'view',
141         ),
142         'bitbucket_url': version.get_bitbucket_url(
143             docroot,
144             page_slug,
145             source_suffix,
146         ),
147         'theme': theme,
148     }
149 
150     html = template_loader.get_template('restapi/footer.html').render(
151         context,
152         request,
153     )
154     resp_data = {
155         'html': html,
156         'version_active': version.active,
157         'version_compare': version_compare_data,
158         'version_supported': version.supported,
159     }
160 
161     # Allow folks to hook onto the footer response for various information
162     # collection, or to modify the resp_data.
163     footer_response.send(
164         sender=None,
165         request=request,
166         context=context,
167         resp_data=resp_data,
168     )
169 
170     return Response(resp_data)
171
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/readthedocs/restapi/views/footer_views.py b/readthedocs/restapi/views/footer_views.py
--- a/readthedocs/restapi/views/footer_views.py
+++ b/readthedocs/restapi/views/footer_views.py
@@ -43,7 +43,7 @@
     }
     if highest_version_obj:
         ret_val['url'] = highest_version_obj.get_absolute_url()
-        ret_val['slug'] = (highest_version_obj.slug,)
+        ret_val['slug'] = highest_version_obj.slug
     if base_version and base_version.slug != LATEST:
         try:
             base_version_comparable = parse_version_failsafe(

{"golden_diff": "diff --git a/readthedocs/restapi/views/footer_views.py b/readthedocs/restapi/views/footer_views.py\n--- a/readthedocs/restapi/views/footer_views.py\n+++ b/readthedocs/restapi/views/footer_views.py\n@@ -43,7 +43,7 @@\n     }\n     if highest_version_obj:\n         ret_val['url'] = highest_version_obj.get_absolute_url()\n-        ret_val['slug'] = (highest_version_obj.slug,)\n+        ret_val['slug'] = highest_version_obj.slug\n     if base_version and base_version.slug != LATEST:\n         try:\n             base_version_comparable = parse_version_failsafe(\n", "issue": "Old version banner uses a version number format present nowhere else\n## Details\n- Project URL: https://github.com/dfhack/dfhack/\n- Build URL: http://dfhack.readthedocs.io/en/v0.40.24-r5/ and http://dfhack.readthedocs.io/en/0.42.06-r1/\n- Read the Docs username:  lethosor\n## Expected result\n\nThe banner on documentation pages for old versions of our project should refer to the newest version using the same version number format present used elsewhere - in this case, \"0.43.03-r1\"\n## Actual result\n\nThe banner refers to \"0.43.3-post1\", which isn't used anywhere else, as far as I can tell.\n## Additional Information\n\nIt would be great if this banner could use the version numbers that our project uses instead of the ones with \"post1\" at the end. I realize the scheme we use is a bit unconventional, but it's tied to another project which uses the \"0.43.03\" format that we don't really have control over.\n\nI made a tentative patch at https://github.com/lethosor/readthedocs.org/commit/7d84130471885905a3f663324af602b7be1f7f64, although I haven't tested it enough to be confident that it'll work for other projects. In particular, I'm not sure in what situations (if any) `slugs` could contain multiple items.\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\"\"\"Endpoint to generate footer HTML.\"\"\"\n\nfrom __future__ import (\n    absolute_import, division, print_function, unicode_literals)\n\nimport six\nfrom django.conf import settings\nfrom django.shortcuts import get_object_or_404\nfrom django.template import loader as template_loader\nfrom rest_framework import decorators, permissions\nfrom rest_framework.renderers import JSONRenderer\nfrom rest_framework.response import Response\nfrom rest_framework_jsonp.renderers import JSONPRenderer\n\nfrom readthedocs.builds.constants import LATEST, TAG\nfrom readthedocs.builds.models import Version\nfrom readthedocs.projects.models import Project\nfrom readthedocs.projects.version_handling import (\n    highest_version, parse_version_failsafe)\nfrom readthedocs.restapi.signals import footer_response\n\n\ndef get_version_compare_data(project, base_version=None):\n    \"\"\"\n    Retrieve metadata about the highest version available for this project.\n\n    :param base_version: We assert whether or not the base_version is also the\n                         highest version in the resulting \"is_highest\" value.\n    \"\"\"\n    versions_qs = project.versions.public().filter(active=True)\n\n    # Take preferences over tags only if the project has at least one tag\n    if versions_qs.filter(type=TAG).exists():\n        versions_qs = versions_qs.filter(type=TAG)\n\n    highest_version_obj, highest_version_comparable = highest_version(\n        versions_qs)\n    ret_val = {\n        'project': six.text_type(highest_version_obj),\n        'version': six.text_type(highest_version_comparable),\n        'is_highest': True,\n    }\n    if highest_version_obj:\n        ret_val['url'] = highest_version_obj.get_absolute_url()\n        ret_val['slug'] = (highest_version_obj.slug,)\n    if base_version and base_version.slug != LATEST:\n        try:\n            base_version_comparable = parse_version_failsafe(\n                base_version.verbose_name)\n            if base_version_comparable:\n                # This is only place where is_highest can get set. All error\n                # cases will be set to True, for non- standard versions.\n                ret_val['is_highest'] = (\n                    base_version_comparable >= highest_version_comparable)\n            else:\n                ret_val['is_highest'] = True\n        except (Version.DoesNotExist, TypeError):\n            ret_val['is_highest'] = True\n    return ret_val\n\n\n@decorators.api_view(['GET'])\n@decorators.permission_classes((permissions.AllowAny,))\n@decorators.renderer_classes((JSONRenderer, JSONPRenderer))\ndef footer_html(request):\n    \"\"\"Render and return footer markup.\"\"\"\n    # TODO refactor this function\n    # pylint: disable=too-many-locals\n    project_slug = request.GET.get('project', None)\n    version_slug = request.GET.get('version', None)\n    page_slug = request.GET.get('page', None)\n    theme = request.GET.get('theme', False)\n    docroot = request.GET.get('docroot', '')\n    subproject = request.GET.get('subproject', False)\n    source_suffix = request.GET.get('source_suffix', '.rst')\n\n    # Hack in a fix for missing version slug deploy that went out a while back\n    if version_slug == '':\n        version_slug = LATEST\n\n    new_theme = (theme == 'sphinx_rtd_theme')\n    using_theme = (theme == 'default')\n    project = get_object_or_404(Project, slug=project_slug)\n    version = get_object_or_404(\n        Version.objects.public(\n            request.user, project=project, only_active=False),\n        slug__iexact=version_slug)\n    main_project = project.main_language_project or project\n\n    if page_slug and page_slug != 'index':\n        if (main_project.documentation_type == 'sphinx_htmldir' or\n                main_project.documentation_type == 'mkdocs'):\n            path = page_slug + '/'\n        elif main_project.documentation_type == 'sphinx_singlehtml':\n            path = 'index.html#document-' + page_slug\n        else:\n            path = page_slug + '.html'\n    else:\n        path = ''\n\n    version_compare_data = get_version_compare_data(project, version)\n\n    context = {\n        'project': project,\n        'version': version,\n        'path': path,\n        'downloads': version.get_downloads(pretty=True),\n        'current_version': version.verbose_name,\n        'versions': project.ordered_active_versions(user=request.user),\n        'main_project': main_project,\n        'translations': main_project.translations.all(),\n        'current_language': project.language,\n        'using_theme': using_theme,\n        'new_theme': new_theme,\n        'settings': settings,\n        'subproject': subproject,\n        'github_edit_url': version.get_github_url(\n            docroot,\n            page_slug,\n            source_suffix,\n            'edit',\n        ),\n        'github_view_url': version.get_github_url(\n            docroot,\n            page_slug,\n            source_suffix,\n            'view',\n        ),\n        'gitlab_edit_url': version.get_gitlab_url(\n            docroot,\n            page_slug,\n            source_suffix,\n            'edit',\n        ),\n        'gitlab_view_url': version.get_gitlab_url(\n            docroot,\n            page_slug,\n            source_suffix,\n            'view',\n        ),\n        'bitbucket_url': version.get_bitbucket_url(\n            docroot,\n            page_slug,\n            source_suffix,\n        ),\n        'theme': theme,\n    }\n\n    html = template_loader.get_template('restapi/footer.html').render(\n        context,\n        request,\n    )\n    resp_data = {\n        'html': html,\n        'version_active': version.active,\n        'version_compare': version_compare_data,\n        'version_supported': version.supported,\n    }\n\n    # Allow folks to hook onto the footer response for various information\n    # collection, or to modify the resp_data.\n    footer_response.send(\n        sender=None,\n        request=request,\n        context=context,\n        resp_data=resp_data,\n    )\n\n    return Response(resp_data)\n", "path": "readthedocs/restapi/views/footer_views.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n\"\"\"Endpoint to generate footer HTML.\"\"\"\n\nfrom __future__ import (\n    absolute_import, division, print_function, unicode_literals)\n\nimport six\nfrom django.conf import settings\nfrom django.shortcuts import get_object_or_404\nfrom django.template import loader as template_loader\nfrom rest_framework import decorators, permissions\nfrom rest_framework.renderers import JSONRenderer\nfrom rest_framework.response import Response\nfrom rest_framework_jsonp.renderers import JSONPRenderer\n\nfrom readthedocs.builds.constants import LATEST, TAG\nfrom readthedocs.builds.models import Version\nfrom readthedocs.projects.models import Project\nfrom readthedocs.projects.version_handling import (\n    highest_version, parse_version_failsafe)\nfrom readthedocs.restapi.signals import footer_response\n\n\ndef get_version_compare_data(project, base_version=None):\n    \"\"\"\n    Retrieve metadata about the highest version available for this project.\n\n    :param base_version: We assert whether or not the base_version is also the\n                         highest version in the resulting \"is_highest\" value.\n    \"\"\"\n    versions_qs = project.versions.public().filter(active=True)\n\n    # Take preferences over tags only if the project has at least one tag\n    if versions_qs.filter(type=TAG).exists():\n        versions_qs = versions_qs.filter(type=TAG)\n\n    highest_version_obj, highest_version_comparable = highest_version(\n        versions_qs)\n    ret_val = {\n        'project': six.text_type(highest_version_obj),\n        'version': six.text_type(highest_version_comparable),\n        'is_highest': True,\n    }\n    if highest_version_obj:\n        ret_val['url'] = highest_version_obj.get_absolute_url()\n        ret_val['slug'] = highest_version_obj.slug\n    if base_version and base_version.slug != LATEST:\n        try:\n            base_version_comparable = parse_version_failsafe(\n                base_version.verbose_name)\n            if base_version_comparable:\n                # This is only place where is_highest can get set. All error\n                # cases will be set to True, for non- standard versions.\n                ret_val['is_highest'] = (\n                    base_version_comparable >= highest_version_comparable)\n            else:\n                ret_val['is_highest'] = True\n        except (Version.DoesNotExist, TypeError):\n            ret_val['is_highest'] = True\n    return ret_val\n\n\n@decorators.api_view(['GET'])\n@decorators.permission_classes((permissions.AllowAny,))\n@decorators.renderer_classes((JSONRenderer, JSONPRenderer))\ndef footer_html(request):\n    \"\"\"Render and return footer markup.\"\"\"\n    # TODO refactor this function\n    # pylint: disable=too-many-locals\n    project_slug = request.GET.get('project', None)\n    version_slug = request.GET.get('version', None)\n    page_slug = request.GET.get('page', None)\n    theme = request.GET.get('theme', False)\n    docroot = request.GET.get('docroot', '')\n    subproject = request.GET.get('subproject', False)\n    source_suffix = request.GET.get('source_suffix', '.rst')\n\n    # Hack in a fix for missing version slug deploy that went out a while back\n    if version_slug == '':\n        version_slug = LATEST\n\n    new_theme = (theme == 'sphinx_rtd_theme')\n    using_theme = (theme == 'default')\n    project = get_object_or_404(Project, slug=project_slug)\n    version = get_object_or_404(\n        Version.objects.public(\n            request.user, project=project, only_active=False),\n        slug__iexact=version_slug)\n    main_project = project.main_language_project or project\n\n    if page_slug and page_slug != 'index':\n        if (main_project.documentation_type == 'sphinx_htmldir' or\n                main_project.documentation_type == 'mkdocs'):\n            path = page_slug + '/'\n        elif main_project.documentation_type == 'sphinx_singlehtml':\n            path = 'index.html#document-' + page_slug\n        else:\n            path = page_slug + '.html'\n    else:\n        path = ''\n\n    version_compare_data = get_version_compare_data(project, version)\n\n    context = {\n        'project': project,\n        'version': version,\n        'path': path,\n        'downloads': version.get_downloads(pretty=True),\n        'current_version': version.verbose_name,\n        'versions': project.ordered_active_versions(user=request.user),\n        'main_project': main_project,\n        'translations': main_project.translations.all(),\n        'current_language': project.language,\n        'using_theme': using_theme,\n        'new_theme': new_theme,\n        'settings': settings,\n        'subproject': subproject,\n        'github_edit_url': version.get_github_url(\n            docroot,\n            page_slug,\n            source_suffix,\n            'edit',\n        ),\n        'github_view_url': version.get_github_url(\n            docroot,\n            page_slug,\n            source_suffix,\n            'view',\n        ),\n        'gitlab_edit_url': version.get_gitlab_url(\n            docroot,\n            page_slug,\n            source_suffix,\n            'edit',\n        ),\n        'gitlab_view_url': version.get_gitlab_url(\n            docroot,\n            page_slug,\n            source_suffix,\n            'view',\n        ),\n        'bitbucket_url': version.get_bitbucket_url(\n            docroot,\n            page_slug,\n            source_suffix,\n        ),\n        'theme': theme,\n    }\n\n    html = template_loader.get_template('restapi/footer.html').render(\n        context,\n        request,\n    )\n    resp_data = {\n        'html': html,\n        'version_active': version.active,\n        'version_compare': version_compare_data,\n        'version_supported': version.supported,\n    }\n\n    # Allow folks to hook onto the footer response for various information\n    # collection, or to modify the resp_data.\n    footer_response.send(\n        sender=None,\n        request=request,\n        context=context,\n        resp_data=resp_data,\n    )\n\n    return Response(resp_data)\n", "path": "readthedocs/restapi/views/footer_views.py"}]}