Skip to content

Add APIv3 version edit URL #7594

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 4 commits into from
Jun 4, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions docs/api/v3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ Version detail
},
"urls": {
"documentation": "https://pip.pypa.io/en/stable/",
"edit": "https://readthedocs.org/dashboard/pip/version/stable/edit/",
"vcs": "https://github.com/pypa/pip/tree/19.0.2"
},
"_links": {
Expand Down
12 changes: 11 additions & 1 deletion readthedocs/api/v3/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,23 @@ def get_project(self, obj):
return self._absolute_url(path)


class VersionURLsSerializer(serializers.Serializer):
class VersionURLsSerializer(BaseLinksSerializer, serializers.Serializer):
documentation = serializers.SerializerMethodField()
edit = serializers.SerializerMethodField()
vcs = serializers.URLField(source='vcs_url')

def get_documentation(self, obj):
return obj.project.get_docs_url(version_slug=obj.slug,)

def get_edit(self, obj):
path = reverse(
'project_version_detail',
kwargs={
'project_slug': obj.project.slug,
'version_slug': obj.slug,
})
return self._absolute_url(path)


class VersionSerializer(FlexFieldsModelSerializer):

Expand Down
1 change: 1 addition & 0 deletions readthedocs/api/v3/tests/responses/projects-detail.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"type": "tag",
"urls": {
"documentation": "http://project.readthedocs.io/en/v1.0/",
"edit": "https://readthedocs.org/dashboard/project/version/v1.0/",
"vcs": "https://github.com/rtfd/project/tree/v1.0/"
},
"verbose_name": "v1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
"type": "tag",
"urls": {
"documentation": "http://project.readthedocs.io/en/v1.0/",
"edit": "https://readthedocs.org/dashboard/project/version/v1.0/",
"vcs": "https://github.com/rtfd/project/tree/v1.0/"
},
"verbose_name": "v1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"type": "tag",
"urls": {
"documentation": "http://project.readthedocs.io/en/v1.0/",
"edit": "https://readthedocs.org/dashboard/project/version/v1.0/",
"vcs": "https://github.com/rtfd/project/tree/v1.0/"
},
"verbose_name": "v1.0"
Expand Down