Browse Source

Update ApprovalAPI to handle image data

pull/1370/head
Hironsan 3 years ago
parent
commit
9aabad5ea3
2 changed files with 8 additions and 8 deletions
  1. 4
      backend/api/urls.py
  2. 12
      backend/api/views/annotation.py

4
backend/api/urls.py

@ -63,8 +63,8 @@ urlpatterns_project = [
name='image_detail'
),
path(
route='docs/<int:doc_id>/approve-labels',
view=views.ApproveLabelsAPI.as_view(),
route='approval/<int:data_id>',
view=views.ApprovalAPI.as_view(),
name='approve_labels'
),
path(

12
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)
Loading…
Cancel
Save