Commit 02188b0a authored by Michal Čihař's avatar Michal Čihař

Include parent objects nested

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 818d1a8d
......@@ -24,7 +24,17 @@ from weblate.trans.models import Project, SubProject, Translation
from weblate.lang.models import Language
class LanguageSerializer(serializers.ModelSerializer):
class Meta(object):
model = Language
fields = (
'id', 'code', 'name', 'nplurals', 'pluralequation', 'direction',
)
class ProjectSerializer(serializers.ModelSerializer):
source_language = LanguageSerializer(read_only=True)
class Meta(object):
model = Project
fields = (
......@@ -33,6 +43,8 @@ class ProjectSerializer(serializers.ModelSerializer):
class ComponentSerializer(serializers.ModelSerializer):
project = ProjectSerializer(read_only=True)
class Meta(object):
model = SubProject
fields = (
......@@ -43,6 +55,9 @@ class ComponentSerializer(serializers.ModelSerializer):
class TranslationSerializer(serializers.ModelSerializer):
subproject = ComponentSerializer(read_only=True)
language = LanguageSerializer(read_only=True)
class Meta(object):
model = Translation
fields = (
......@@ -51,11 +66,3 @@ class TranslationSerializer(serializers.ModelSerializer):
'total_words', 'failing_checks', 'have_suggestion', 'have_comment',
'language_code', 'filename', 'revision',
)
class LanguageSerializer(serializers.ModelSerializer):
class Meta(object):
model = Language
fields = (
'id', 'code', 'name', 'nplurals', 'pluralequation', 'direction',
)
......@@ -33,6 +33,7 @@ class ProjectViewSet(viewsets.ReadOnlyModelViewSet):
"""
queryset = Project.objects.none()
serializer_class = ProjectSerializer
lookup_field = 'slug'
def get_queryset(self):
return Project.objects.all_acl(self.request.user)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment