From 13ab4ea2c2f4c478e9a00b04c74b8d501421a8be Mon Sep 17 00:00:00 2001 From: Alexandr Karpov Date: Tue, 1 Nov 2022 18:55:21 +0300 Subject: [PATCH] bug fixes --- image_markuper/dicom/api/serializers.py | 2 +- image_markuper/dicom/api/views.py | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/image_markuper/dicom/api/serializers.py b/image_markuper/dicom/api/serializers.py index f96f4a7..81779dd 100644 --- a/image_markuper/dicom/api/serializers.py +++ b/image_markuper/dicom/api/serializers.py @@ -176,4 +176,4 @@ class ProjectSerializer(serializers.ModelSerializer): class Meta: model = Project - fields = ["files", "created"] + fields = ["files", "slug", "created"] diff --git a/image_markuper/dicom/api/views.py b/image_markuper/dicom/api/views.py index 1d78653..ccdf4fd 100644 --- a/image_markuper/dicom/api/views.py +++ b/image_markuper/dicom/api/views.py @@ -102,7 +102,7 @@ class SmartFileUploadApi(GenericAPIView): request.user, ) return Response( - ListDicomSerializer(project.files.all(), many=True).data, + ProjectSerializer(project, context={"request": request}).data, status=status.HTTP_201_CREATED, ) @@ -125,7 +125,7 @@ class AddDicomProjectApi(GenericAPIView): slug, ) return Response( - ListDicomSerializer(project.files.all(), many=True).data, + ProjectSerializer(project, context={"request": request}).data, status=status.HTTP_201_CREATED, ) @@ -134,17 +134,16 @@ class DeleteDicomProjectApi(GenericAPIView): serializer_class = SmartFileUploadSerializer @extend_schema( - operation_id="add_dicom_to_project", + operation_id="delete_dicom_from_project", request=None, responses={200: ListDicomSerializer(many=True)}, ) def delete(self, request, slug, dicom_slug): project = get_object_or_404(Project, slug=slug) project.files.filter(slug=dicom_slug).delete() + return Response( - ListDicomSerializer( - project.files.all(), many=True, context={"request": request} - ).data, + ProjectSerializer(project, context={"request": request}).data, status=status.HTTP_200_OK, )