From 9aabad5ea3bdc2372bc6ac226270dbc0de0a9e5f Mon Sep 17 00:00:00 2001 From: Hironsan Date: Wed, 12 May 2021 15:05:23 +0900 Subject: [PATCH] Update ApprovalAPI to handle image data --- backend/api/urls.py | 4 ++-- backend/api/views/annotation.py | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/backend/api/urls.py b/backend/api/urls.py index 4e23747b..61f94e42 100644 --- a/backend/api/urls.py +++ b/backend/api/urls.py @@ -63,8 +63,8 @@ urlpatterns_project = [ name='image_detail' ), path( - route='docs//approve-labels', - view=views.ApproveLabelsAPI.as_view(), + route='approval/', + view=views.ApprovalAPI.as_view(), name='approve_labels' ), path( diff --git a/backend/api/views/annotation.py b/backend/api/views/annotation.py index d770a252..a119d51c 100644 --- a/backend/api/views/annotation.py +++ b/backend/api/views/annotation.py @@ -4,7 +4,7 @@ from rest_framework.permissions import IsAuthenticated from rest_framework.response import Response from rest_framework.views import APIView -from ..models import Document, Project +from ..models import Example, Project from ..permissions import (IsAnnotationApprover, IsInProjectOrAdmin, IsOwnAnnotation, IsProjectAdmin) from ..serializers import ApproverSerializer, get_annotation_serializer @@ -69,12 +69,12 @@ class AnnotationDetail(generics.RetrieveUpdateDestroyAPIView): return self.queryset -class ApproveLabelsAPI(APIView): +class ApprovalAPI(APIView): permission_classes = [IsAuthenticated & (IsAnnotationApprover | IsProjectAdmin)] def post(self, request, *args, **kwargs): approved = self.request.data.get('approved', True) - document = get_object_or_404(Document, pk=self.kwargs['doc_id']) - document.annotations_approved_by = self.request.user if approved else None - document.save() - return Response(ApproverSerializer(document).data) + example = get_object_or_404(Example, pk=self.kwargs['data_id']) + example.annotations_approved_by = self.request.user if approved else None + example.save() + return Response(ApproverSerializer(example).data)