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
e91b10ba
Commit
e91b10ba
authored
Mar 25, 2016
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Export monolingual and new language base files
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
179280e9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
1 deletion
+62
-1
docs/api.rst
docs/api.rst
+8
-0
weblate/api/tests.py
weblate/api/tests.py
+14
-0
weblate/api/views.py
weblate/api/views.py
+40
-1
No files found.
docs/api.rst
View file @
e91b10ba
...
@@ -84,6 +84,14 @@ Components
...
@@ -84,6 +84,14 @@ Components
:query operation: Operation to perform, one of ``push``, ``pull``, ``commit``, ``reset``
:query operation: Operation to perform, one of ``push``, ``pull``, ``commit``, ``reset``
.. http:get:: /api/components/(string:project)/(string:component)/monolingual_base/
Returns base file for monolingual translations.
.. http:get:: /api/components/(string:project)/(string:component)/new_template/
Returns template file for new translations.
Translations
Translations
++++++++++++
++++++++++++
...
...
weblate/api/tests.py
View file @
e91b10ba
...
@@ -202,6 +202,20 @@ class ComponentAPITest(APIBaseTest):
...
@@ -202,6 +202,20 @@ class ComponentAPITest(APIBaseTest):
}
}
)
)
def
test_new_template
(
self
):
self
.
do_request
(
'api:component-new-template'
,
self
.
component_kwargs
,
code
=
404
,
)
def
test_monolingual
(
self
):
self
.
do_request
(
'api:component-monolingual-base'
,
self
.
component_kwargs
,
code
=
404
,
)
class
LanguageAPITest
(
APIBaseTest
):
class
LanguageAPITest
(
APIBaseTest
):
def
test_list_languages
(
self
):
def
test_list_languages
(
self
):
...
...
weblate/api/views.py
View file @
e91b10ba
...
@@ -18,9 +18,11 @@
...
@@ -18,9 +18,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
import
os.path
from
django.core.exceptions
import
PermissionDenied
from
django.core.exceptions
import
PermissionDenied
from
django.shortcuts
import
get_object_or_404
from
django.shortcuts
import
get_object_or_404
from
django.http
import
Http404
from
django.http
import
Http404
,
HttpResponse
from
rest_framework
import
parsers
,
viewsets
from
rest_framework
import
parsers
,
viewsets
from
rest_framework.decorators
import
detail_route
from
rest_framework.decorators
import
detail_route
...
@@ -175,6 +177,43 @@ class ComponentViewSet(MultipleFieldMixin, WeblateViewSet):
...
@@ -175,6 +177,43 @@ class ComponentViewSet(MultipleFieldMixin, WeblateViewSet):
return
Response
(
data
=
LockSerializer
(
obj
).
data
)
return
Response
(
data
=
LockSerializer
(
obj
).
data
)
def
download_file
(
self
,
filename
,
content_type
):
"""Wrapper for file download"""
with
open
(
filename
,
'rb'
)
as
handle
:
response
=
HttpResponse
(
handle
.
read
(),
content_type
=
content_type
)
response
[
'Content-Disposition'
]
=
\
'attachment; filename="{0}"'
.
format
(
os
.
path
.
basename
(
filename
)
)
return
response
@
detail_route
(
methods
=
[
'get'
])
def
monolingual_base
(
self
,
request
,
**
kwargs
):
obj
=
self
.
get_object
()
if
not
obj
.
template
:
raise
Http404
(
'No template found!'
)
return
self
.
download_file
(
obj
.
get_template_filename
(),
obj
.
template_store
.
mimetype
)
@
detail_route
(
methods
=
[
'get'
])
def
new_template
(
self
,
request
,
**
kwargs
):
obj
=
self
.
get_object
()
if
not
obj
.
new_base
:
raise
Http404
(
'No file found!'
)
return
self
.
download_file
(
obj
.
get_new_base_filename
(),
'application/binary'
,
)
class
TranslationViewSet
(
MultipleFieldMixin
,
WeblateViewSet
):
class
TranslationViewSet
(
MultipleFieldMixin
,
WeblateViewSet
):
"""Translation components API.
"""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