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
3a8239cb
Commit
3a8239cb
authored
Mar 22, 2016
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add read only views for components
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
335fc235
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
7 deletions
+32
-7
weblate/api/serializers.py
weblate/api/serializers.py
+12
-2
weblate/api/urls.py
weblate/api/urls.py
+2
-1
weblate/api/views.py
weblate/api/views.py
+18
-4
No files found.
weblate/api/serializers.py
View file @
3a8239cb
...
...
@@ -20,12 +20,22 @@
from
rest_framework
import
serializers
from
weblate.trans.models
import
Project
from
weblate.trans.models
import
Project
,
SubProject
class
ProjectSerializer
(
serializers
.
ModelSerializer
):
class
Meta
(
object
):
model
=
Project
fields
=
(
'id'
,
'name'
,
'slug'
,
'web'
,
'source_language'
'id'
,
'name'
,
'slug'
,
'web'
,
'source_language'
,
)
class
ComponentSerializer
(
serializers
.
ModelSerializer
):
class
Meta
(
object
):
model
=
SubProject
fields
=
(
'id'
,
'name'
,
'slug'
,
'project'
,
'vcs'
,
'repo'
,
'git_export'
,
'branch'
,
'filemask'
,
'template'
,
'file_format'
,
'license'
,
'license_url'
,
)
weblate/api/urls.py
View file @
3a8239cb
...
...
@@ -23,11 +23,12 @@ from __future__ import unicode_literals
from
django.conf.urls
import
url
,
include
from
rest_framework
import
routers
,
serializers
,
viewsets
from
weblate.api.views
import
ProjectViewSet
from
weblate.api.views
import
ProjectViewSet
,
ComponentViewSet
# Routers provide an easy way of automatically determining the URL conf.
router
=
routers
.
DefaultRouter
()
router
.
register
(
r'projects'
,
ProjectViewSet
)
router
.
register
(
r'components'
,
ComponentViewSet
)
# Wire up our API using automatic URL routing.
...
...
weblate/api/views.py
View file @
3a8239cb
...
...
@@ -20,16 +20,30 @@
from
rest_framework
import
viewsets
from
weblate.api.serializers
import
ProjectSerializer
from
weblate.trans.models
import
Project
from
weblate.api.serializers
import
ProjectSerializer
,
ComponentSerializer
from
weblate.trans.models
import
Project
,
SubProject
class
ProjectViewSet
(
viewsets
.
ReadOnlyModelViewSet
):
"""
ViewSet for viewing projects.
"""Translation projects API.
"""
queryset
=
Project
.
objects
.
none
()
serializer_class
=
ProjectSerializer
def
get_queryset
(
self
):
return
Project
.
objects
.
all_acl
(
self
.
request
.
user
)
class
ComponentViewSet
(
viewsets
.
ReadOnlyModelViewSet
):
"""Translation components API.
"""
queryset
=
SubProject
.
objects
.
none
()
serializer_class
=
ComponentSerializer
def
get_queryset
(
self
):
acl_projects
,
filtered
=
Project
.
objects
.
get_acl_status
(
self
.
request
.
user
)
if
filtered
:
return
SubProject
.
objects
.
filter
(
project__in
=
acl_projects
)
return
SubProject
.
objects
.
all
()
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