Remove /api/v1/version/{}/highest endpoint (#2862)

This endpoint was used by an old Javascript file to check if the
documentation shown was old and show a NOTE in the html. Now, that is
included in the footer of the the page at rendering time.
gthank-master
Manuel Kaufmann 2017-05-24 18:19:37 -03:00 committed by Anthony
parent 277457c402
commit 27e8dc3b65
4 changed files with 0 additions and 200 deletions

View File

@ -44,9 +44,6 @@ Alternatively you can try with the following value::
#val = api.version('pip').get()
#val = api.version('pip').get(slug='1.0.1')
#val = api.version('pip').highest.get()
#val = api.version('pip').highest('0.8').get()
API Endpoints
-------------
@ -484,59 +481,6 @@ Version
Filtering Examples
------------------
Find Highest Version
~~~~~~~~~~~~~~~~~~~~
::
http://readthedocs.org/api/v1/version/pip/highest/?format=json
.. http:get:: /api/v1/version/{id}/highest/
:arg id: A Version id.
Retrieve highest version.
.. sourcecode:: js
{
"is_highest": true,
"project": "Version 1.0.1 of pip (5476)",
"slug": [
"1.0.1"
],
"url": "/docs/pip/en/1.0.1/",
"version": "1.0.1"
}
Compare Highest Version
~~~~~~~~~~~~~~~~~~~~~~~
This will allow you to compare whether a certain version is the highest version of a specific project. The below query should return a `'is_highest': false` in the returned dictionary.
::
http://readthedocs.org/api/v1/version/pip/highest/0.8/?format=json
.. http:get:: /api/v1/version/{id}/highest/{version}
:arg id: A Version id.
:arg version: A Version number or string.
Retrieve highest version.
.. sourcecode:: js
{
"is_highest": false,
"project": "Version 1.0.1 of pip (5476)",
"slug": [
"1.0.1"
],
"url": "/docs/pip/en/1.0.1/",
"version": "1.0.1"
}
File Search
~~~~~~~~~~~

View File

@ -1,95 +0,0 @@
(function () {
var checkVersion = function (slug, version) {
var versionURL = ["//readthedocs.org/api/v1/version/", slug,
"/highest/", version, "/?callback=?"].join("");
$.getJSON(versionURL, onData);
function onData (data) {
if (data.is_highest) {
return;
}
var currentURL = window.location.pathname.replace(version, data.slug),
warning = $('<div class="admonition note"> <p class="first \
admonition-title">Note</p> <p class="last"> \
You are not using the most up to date version \
of the library. <a href="#"></a> is the newest version.</p>\
</div>');
warning
.find('a')
.attr('href', currentURL)
.text(data.version);
$("div.body").prepend(warning);
}
};
var getVersions = function (slug, version) {
var versionsURL = ["//readthedocs.org/api/v1/version/", slug,
"/?active=True&callback=?"].join("");
return $.getJSON(versionsURL, gotData);
function gotData (data) {
var items = $('<ul />')
, currentURL
, versionItem
, object
for (var key in data.objects) {
object = data.objects[key]
currentURL = window.location.pathname.replace(version, object.slug)
versionItem = $('<a href="#"></a>')
.attr('href', currentURL)
.text(object.slug)
.appendTo($('<li />').appendTo(items))
}
// update widget and sidebar
$('#version_menu, .version-listing, #sidebar_versions').html(items.html())
}
};
$(function () {
// Code executed on load
var slug = window.doc_slug,
version = window.doc_version;
// Show action on hover
$(".module-item-menu").hover(
function () {
$(".hidden-child", this).show();
}, function () {
$(".hidden-child", this).hide();
}
);
// This is a deprecated API and file, so removing this to reduce errors
// on our servers.
// checkVersion(slug, version);
getVersions(slug, version);
/*
* Grok the Docs event handling
* This will allow you to better
* understand whats happening in your docs,
* once fully rolled out.
*/
// $.ajax({
// url: "https://api.grokthedocs.com/static/javascript/bundle-client.js",
// crossDomain: true,
// dataType: "script",
// cache: true,
// });
});
})();

View File

@ -19,7 +19,6 @@ from readthedocs.builds.constants import LATEST
from readthedocs.builds.models import Version
from readthedocs.core.utils import trigger_build
from readthedocs.projects.models import Project, ImportedFile
from readthedocs.restapi.views.footer_views import get_version_compare_data
from .utils import SearchMixin, PostAuthentication
@ -139,18 +138,6 @@ class VersionResource(ModelResource):
self._meta.queryset = Version.objects.api(user=request.user)
return super(VersionResource, self).get_object_list(request)
def version_compare(self, request, project_slug, base=None, **__):
project = get_object_or_404(Project, slug=project_slug)
if base and base != LATEST:
try:
base_version = project.versions.get(slug=base)
except (Version.DoesNotExist, TypeError):
base_version = None
else:
base_version = None
ret_val = get_version_compare_data(project, base_version)
return self.create_response(request, ret_val)
def build_version(self, request, **kwargs):
project = get_object_or_404(Project, slug=kwargs['project_slug'])
version = kwargs.get('version_slug', LATEST)
@ -164,15 +151,6 @@ class VersionResource(ModelResource):
% self._meta.resource_name,
self.wrap_view('get_schema'),
name="api_get_schema"),
url((r"^(?P<resource_name>%s)/(?P<project_slug>[a-z-_]+)/highest/"
r"(?P<base>.+)/$")
% self._meta.resource_name,
self.wrap_view('version_compare'),
name="version_compare"),
url(r"^(?P<resource_name>%s)/(?P<project_slug>[a-z-_]+)/highest/$"
% self._meta.resource_name,
self.wrap_view('version_compare'),
name="version_compare"),
url(r"^(?P<resource_name>%s)/(?P<project__slug>[a-z-_]+[a-z0-9-_]+)/$" # noqa
% self._meta.resource_name,
self.wrap_view('dispatch_list'),

View File

@ -207,33 +207,6 @@ class APITests(TestCase):
resp = self.client.get("/api/v1/project/", data={"format": "json"})
self.assertEqual(resp.status_code, 200)
def test_not_highest(self):
resp = self.client.get(
"http://testserver/api/v1/version/read-the-docs/highest/0.2.1/",
data={"format": "json"}
)
self.assertEqual(resp.status_code, 200)
obj = json.loads(resp.content)
self.assertEqual(obj['is_highest'], False)
def test_latest_version_highest(self):
resp = self.client.get(
"http://testserver/api/v1/version/read-the-docs/highest/latest/",
data={"format": "json"}
)
self.assertEqual(resp.status_code, 200)
obj = json.loads(resp.content)
self.assertEqual(obj['is_highest'], True)
def test_real_highest(self):
resp = self.client.get(
"http://testserver/api/v1/version/read-the-docs/highest/0.2.2/",
data={"format": "json"}
)
self.assertEqual(resp.status_code, 200)
obj = json.loads(resp.content)
self.assertEqual(obj['is_highest'], True)
class APIImportTests(TestCase):