diff --git a/backend/api/urls.py b/backend/api/urls.py index 8ae53e25..ab371440 100644 --- a/backend/api/urls.py +++ b/backend/api/urls.py @@ -43,15 +43,16 @@ urlpatterns_project = [ name='label_detail' ), path( - route='data', + route='examples', view=views.ExampleList.as_view(), - name='data_list' + name='example_list' ), path( - route='data/', + route='examples/', view=views.ExampleDetail.as_view(), - name='data_detail' + name='example_detail' ), + # Todo: remove. path( route='docs', view=views.DocumentList.as_view(), @@ -63,10 +64,11 @@ urlpatterns_project = [ name='doc_detail' ), path( - route='approval/', + route='approval/', view=views.ApprovalAPI.as_view(), name='approve_labels' ), + # Todo: change. path( route='docs//annotations', view=views.AnnotationList.as_view(), @@ -88,7 +90,7 @@ urlpatterns_project = [ name='tag_detail' ), path( - route='docs//comments', + route='examples//comments', view=views.CommentListDoc.as_view(), name='comment_list_doc' ), @@ -98,7 +100,7 @@ urlpatterns_project = [ name='comment_list_project' ), path( - route='docs//comments/', + route='examples//comments/', view=views.CommentDetail.as_view(), name='comment_detail' ), diff --git a/backend/api/views/annotation.py b/backend/api/views/annotation.py index 9b9475e9..0340d115 100644 --- a/backend/api/views/annotation.py +++ b/backend/api/views/annotation.py @@ -75,7 +75,7 @@ class ApprovalAPI(APIView): def post(self, request, *args, **kwargs): approved = self.request.data.get('approved', True) - example = get_object_or_404(Example, pk=self.kwargs['data_id']) + example = get_object_or_404(Example, pk=self.kwargs['example_id']) example.annotations_approved_by = self.request.user if approved else None example.save() return Response(ApproverSerializer(example).data) diff --git a/backend/api/views/comment.py b/backend/api/views/comment.py index 8cc178f8..3e2363e3 100644 --- a/backend/api/views/comment.py +++ b/backend/api/views/comment.py @@ -17,12 +17,12 @@ class CommentListDoc(generics.ListCreateAPIView): def get_queryset(self): queryset = self.model.objects.filter( example__project_id=self.kwargs['project_id'], - example=self.kwargs['doc_id'] + example=self.kwargs['example_id'] ) return queryset def perform_create(self, serializer): - serializer.save(example_id=self.kwargs['doc_id'], user=self.request.user) + serializer.save(example_id=self.kwargs['example_id'], user=self.request.user) class CommentListProject(generics.ListAPIView): diff --git a/backend/api/views/example.py b/backend/api/views/example.py index 1012fb28..ae7e9b96 100644 --- a/backend/api/views/example.py +++ b/backend/api/views/example.py @@ -52,7 +52,7 @@ class ExampleList(generics.ListCreateAPIView): class ExampleDetail(generics.RetrieveUpdateDestroyAPIView): queryset = Example.objects.all() serializer_class = ExampleSerializer - lookup_url_kwarg = 'data_id' + lookup_url_kwarg = 'example_id' permission_classes = [IsAuthenticated & IsInProjectReadOnlyOrAdmin] diff --git a/frontend/repositories/comment/apiCommentRepository.ts b/frontend/repositories/comment/apiCommentRepository.ts index b436c6a3..8cd28c59 100644 --- a/frontend/repositories/comment/apiCommentRepository.ts +++ b/frontend/repositories/comment/apiCommentRepository.ts @@ -14,29 +14,29 @@ export class APICommentRepository implements CommentRepository { return items.map(item => CommentItem.valueOf(item)) } - async list(projectId: string, docId: number): Promise { - const url = `/projects/${projectId}/docs/${docId}/comments` + async list(projectId: string, exampleId: number): Promise { + const url = `/projects/${projectId}/examples/${exampleId}/comments` const response = await this.request.get(url) const items: CommentItemResponse[] = response.data return items.map(item => CommentItem.valueOf(item)) } - async create(projectId: string, docId: number, text: string): Promise { - const url = `/projects/${projectId}/docs/${docId}/comments` - const response = await this.request.post(url, { projectId, docId, text }) + async create(projectId: string, exampleId: number, text: string): Promise { + const url = `/projects/${projectId}/examples/${exampleId}/comments` + const response = await this.request.post(url, { projectId, exampleId, text }) const responseItem: CommentItemResponse = response.data return CommentItem.valueOf(responseItem) } - async update(projectId: string, docId: number, item: CommentItem): Promise { - const url = `/projects/${projectId}/docs/${docId}/comments/${item.id}` + async update(projectId: string, exampleId: number, item: CommentItem): Promise { + const url = `/projects/${projectId}/examples/${exampleId}/comments/${item.id}` const response = await this.request.put(url, item.toObject()) const responseItem: CommentItemResponse = response.data return CommentItem.valueOf(responseItem) } - async delete(projectId: string, docId: number, commentId: number): Promise { - const url = `/projects/${projectId}/docs/${docId}/comments/${commentId}` + async delete(projectId: string, exampleId: number, commentId: number): Promise { + const url = `/projects/${projectId}/examples/${exampleId}/comments/${commentId}` const response = await this.request.delete(url) } diff --git a/frontend/repositories/example/apiDocumentRepository.ts b/frontend/repositories/example/apiDocumentRepository.ts index 290eeda0..cdbcfcd6 100644 --- a/frontend/repositories/example/apiDocumentRepository.ts +++ b/frontend/repositories/example/apiDocumentRepository.ts @@ -9,35 +9,35 @@ export class APIExampleRepository implements ExampleRepository { ) {} async list(projectId: string, { limit = '10', offset = '0', q = '', isChecked = '', filterName = '' }: SearchOption): Promise { - const url = `/projects/${projectId}/data?limit=${limit}&offset=${offset}&q=${q}&${filterName}=${isChecked}` + const url = `/projects/${projectId}/examples?limit=${limit}&offset=${offset}&q=${q}&${filterName}=${isChecked}` const response = await this.request.get(url) return ExampleItemList.valueOf(response.data) } async create(projectId: string, item: ExampleItem): Promise { - const url = `/projects/${projectId}/data` + const url = `/projects/${projectId}/examples` const response = await this.request.post(url, item.toObject()) return ExampleItem.valueOf(response.data) } async update(projectId: string, item: ExampleItem): Promise { - const url = `/projects/${projectId}/data/${item.id}` + const url = `/projects/${projectId}/examples/${item.id}` const response = await this.request.patch(url, item.toObject()) return ExampleItem.valueOf(response.data) } async bulkDelete(projectId: string, ids: number[]): Promise { - const url = `/projects/${projectId}/data` + const url = `/projects/${projectId}/examples` await this.request.delete(url, { ids }) } async deleteAll(projectId: string): Promise { - const url = `/projects/${projectId}/data` + const url = `/projects/${projectId}/examples` await this.request.delete(url) } - async approve(projectId: string, docId: number, approved: boolean): Promise { - const url = `/projects/${projectId}/approval/${docId}` + async approve(projectId: string, exampleId: number, approved: boolean): Promise { + const url = `/projects/${projectId}/approval/${exampleId}` await this.request.post(url, { approved }) } }