Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
65faa05d
Commit
65faa05d
authored
Mar 25, 2016
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add API for listing translations and components
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
c0b416c0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
1 deletion
+54
-1
docs/api.rst
docs/api.rst
+9
-1
weblate/api/tests.py
weblate/api/tests.py
+15
-0
weblate/api/views.py
weblate/api/views.py
+30
-0
No files found.
docs/api.rst
View file @
65faa05d
...
...
@@ -57,6 +57,10 @@ Projects
:query operation: Operation to perform, one of ``push``, ``pull``, ``commit``, ``reset``
.. http:get:: /api/projects/(string:project)/components/
Returns list of translation components in given project.
Components
++++++++++
...
...
@@ -92,6 +96,10 @@ Components
Returns template file for new translations.
.. http:get:: /api/components/(string:project)/(string:component)/translations/
Returns list of translation objects in given component.
Translations
++++++++++++
...
...
@@ -217,7 +225,7 @@ Weblate provides various exports to allow you further process the data.
.. deprecated:: 2.6
Please use :http:get:`/api/
translations/(string:project)/(string:component)/(string:language)
/`
Please use :http:get:`/api/
components/(string:project)/(string:component)/translations
/`
instead, it allows to access ACL controlled projects as well.
Retrieves statistics for given component in JSON format. Optionally as
...
...
weblate/api/tests.py
View file @
65faa05d
...
...
@@ -65,6 +65,7 @@ class APIBaseTest(APITestCase, RepoTestMixin):
self
.
assertEqual
(
response
.
status_code
,
code
)
if
data
is
not
None
:
self
.
assertEqual
(
response
.
data
,
data
)
return
response
class
ProjectAPITest
(
APIBaseTest
):
...
...
@@ -130,6 +131,13 @@ class ProjectAPITest(APIBaseTest):
}
)
def
test_components
(
self
):
request
=
self
.
do_request
(
'api:project-components'
,
self
.
project_kwargs
,
)
self
.
assertEqual
(
request
.
data
[
'count'
],
1
)
class
ComponentAPITest
(
APIBaseTest
):
def
test_list_components
(
self
):
...
...
@@ -216,6 +224,13 @@ class ComponentAPITest(APIBaseTest):
code
=
404
,
)
def
test_translations
(
self
):
request
=
self
.
do_request
(
'api:component-translations'
,
self
.
component_kwargs
,
)
self
.
assertEqual
(
request
.
data
[
'count'
],
3
)
class
LanguageAPITest
(
APIBaseTest
):
def
test_list_languages
(
self
):
...
...
weblate/api/views.py
View file @
65faa05d
...
...
@@ -138,6 +138,21 @@ class ProjectViewSet(WeblateViewSet):
'source_language'
)
@
detail_route
(
methods
=
[
'get'
])
def
components
(
self
,
request
,
**
kwargs
):
obj
=
self
.
get_object
()
queryset
=
obj
.
subproject_set
.
all
()
page
=
self
.
paginate_queryset
(
queryset
)
serializer
=
ComponentSerializer
(
page
,
many
=
True
,
context
=
{
'request'
:
request
}
)
return
self
.
get_paginated_response
(
serializer
.
data
)
class
ComponentViewSet
(
MultipleFieldMixin
,
WeblateViewSet
):
"""Translation components API.
...
...
@@ -214,6 +229,21 @@ class ComponentViewSet(MultipleFieldMixin, WeblateViewSet):
'application/binary'
,
)
@
detail_route
(
methods
=
[
'get'
])
def
translations
(
self
,
request
,
**
kwargs
):
obj
=
self
.
get_object
()
queryset
=
obj
.
translation_set
.
all
()
page
=
self
.
paginate_queryset
(
queryset
)
serializer
=
TranslationSerializer
(
page
,
many
=
True
,
context
=
{
'request'
:
request
}
)
return
self
.
get_paginated_response
(
serializer
.
data
)
class
TranslationViewSet
(
MultipleFieldMixin
,
WeblateViewSet
):
"""Translation components API.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment