From 1f0f5a46046222d91937a069db99bd8bf42af02f Mon Sep 17 00:00:00 2001 From: Hironsan Date: Thu, 9 Aug 2018 16:34:16 +0900 Subject: [PATCH] Update AnnotationDetail API --- app/db.sqlite3 | Bin 241664 -> 241664 bytes app/server/api.py | 20 ++++++-------------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/app/db.sqlite3 b/app/db.sqlite3 index c2af20fe9d8c4524629d59284db73253bfb9f2d1..28211d564a5df2f3b499a5c79c73ee3b9a58dbf6 100644 GIT binary patch delta 49 zcmZp8z}N7AZ-O+V&qNt#MxVxn)&$0_2~4x~S<*_=6WjmmGj0E`&-|Ak%w6WdTmS&V CzY+`p delta 49 zcmZp8z}N7AZ-O+V_e2?IM(@Ui)&$0_2~4x~Su*m|Q``URGj0E`&-|Ak%w6WdTmS&V CXc7tl diff --git a/app/server/api.py b/app/server/api.py index 7ef7e095..f57e8aaa 100644 --- a/app/server/api.py +++ b/app/server/api.py @@ -132,6 +132,12 @@ class AnnotationList(generics.ListCreateAPIView): class AnnotationDetail(generics.RetrieveUpdateDestroyAPIView): permission_classes = (IsAuthenticated, IsProjectUser, IsOwnAnnotation) + def get_serializer_class(self): + project = get_object_or_404(Project, pk=self.kwargs['project_id']) + self.serializer_class = project.get_annotation_serializer() + + return self.serializer_class + def get_queryset(self): document = get_object_or_404(Document, pk=self.kwargs['doc_id']) self.queryset = document.get_annotations() @@ -144,17 +150,3 @@ class AnnotationDetail(generics.RetrieveUpdateDestroyAPIView): self.check_object_permissions(self.request, obj) return obj - - def put(self, request, *args, **kwargs): - doc = get_object_or_404(Document, pk=self.kwargs['doc_id']) - project = get_object_or_404(Project, pk=self.kwargs['project_id']) - self.serializer_class = project.get_annotation_serializer() - if project.is_type_of(Project.Seq2seq): - text = request.data['text'] - annotation = get_object_or_404(Seq2seqAnnotation, pk=request.data['id']) - annotation.text = text - - annotation.save() - serializer = self.serializer_class(annotation) - - return Response(serializer.data)