Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 0 additions & 56 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------------
Expand Down Expand Up @@ -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
~~~~~~~~~~~
Expand Down
95 changes: 0 additions & 95 deletions media/javascript/rtd.js

This file was deleted.

22 changes: 0 additions & 22 deletions readthedocs/api/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
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

Expand Down Expand Up @@ -139,18 +138,6 @@ def get_object_list(self, request):
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)
Expand All @@ -164,15 +151,6 @@ def override_urls(self):
% 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'),
Expand Down
27 changes: 0 additions & 27 deletions readthedocs/rtd_tests/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,33 +207,6 @@ def test_ensure_get_unauth(self):
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):

Expand Down