Commit ce91f9e6 authored by Michal Čihař's avatar Michal Čihař

Properly use serializers

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 94d13960
...@@ -130,9 +130,19 @@ class TranslationSerializer(serializers.ModelSerializer): ...@@ -130,9 +130,19 @@ class TranslationSerializer(serializers.ModelSerializer):
} }
class LockSerializer(serializers.Serializer): class ReadOnlySerializer(serializers.Serializer):
locked = serializers.BooleanField() def update(self, instance, validated_data):
return None
def create(self, validated_data):
return None
class LockRequestSerializer(serializers.Serializer):
class LockSerializer(serializers.ModelSerializer):
class Meta(object):
model = SubProject
fields = ('locked', )
class LockRequestSerializer(ReadOnlySerializer):
lock = serializers.BooleanField() lock = serializers.BooleanField()
...@@ -24,7 +24,6 @@ from django.http import Http404 ...@@ -24,7 +24,6 @@ from django.http import Http404
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
from rest_framework.exceptions import ParseError
from rest_framework.response import Response from rest_framework.response import Response
from weblate.api.serializers import ( from weblate.api.serializers import (
...@@ -126,7 +125,7 @@ class ComponentViewSet(MultipleFieldMixin, viewsets.ReadOnlyModelViewSet): ...@@ -126,7 +125,7 @@ class ComponentViewSet(MultipleFieldMixin, viewsets.ReadOnlyModelViewSet):
else: else:
obj.do_unlock(request.user) obj.do_unlock(request.user)
return Response(data={'locked': obj.locked}) return Response(data=LockSerializer(obj).data)
class TranslationViewSet(MultipleFieldMixin, FileExportViewSet): class TranslationViewSet(MultipleFieldMixin, FileExportViewSet):
......
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