권주희

update the destroy api

...@@ -58,13 +58,14 @@ class ItemViewSet(viewsets.ViewSet): ...@@ -58,13 +58,14 @@ class ItemViewSet(viewsets.ViewSet):
58 def destroy(self, request, pk): 58 def destroy(self, request, pk):
59 if request.method == 'DELETE': 59 if request.method == 'DELETE':
60 print(pk) 60 print(pk)
61 - item = Item.objects.get(item_id = pk) 61 + item = get_object_or_None(Item, item_id=pk)
62 - if item.is_folder == True: # 폴더는 삭제 안되도록 처리 62 + if item != None:
63 - return Response({'message': 'This item is folder.'}, status=status.HTTP_200_OK) 63 + if item.is_folder == True: # 폴더는 삭제 안되도록 처리
64 - item.is_deleted = True 64 + return Response({'message': 'This item is folder.'}, status=status.HTTP_200_OK)
65 - # item.delete() 이거 하면 완전 삭제되어버림 is deleted True 면 휴지통에서 리스트 조회할 수 있도록! 65 + item.is_deleted = True
66 - return Response({'message': 'delete complete'},status=status.HTTP_200_OK) 66 + # item.delete() 이거 하면 완전 삭제되어버림 is deleted True 면 휴지통에서 리스트 조회할 수 있도록!
67 - return Response({'message': 'item is not existed.'}, status=status.HTTP_204_NO_CONTENT) 67 + return Response({'message': 'delete complete'},status=status.HTTP_200_OK)
68 + return Response({'message': 'item is not existed.'}, status=status.HTTP_204_NO_CONTENT)
68 69
69 def get_permissions(self): 70 def get_permissions(self):
70 try: 71 try:
......