권주희

implement delete permanently api

......@@ -221,6 +221,16 @@ class ItemViewSet(viewsets.ViewSet):
return Response({'message': 'restore complete'}, status=status.HTTP_200_OK)
return Response({'message': 'item is not existed.'}, status=status.HTTP_204_NO_CONTENT)
@action(methods=['DELETE'], detail=True, permission_classes=[AllowAny], url_path='delete', url_name='delete')
def delete(self, request, pk):
if request.method == 'DELETE':
item = get_object_or_None(Item, item_id=pk)
if item != None:
if item.is_folder == True: # 폴더는 삭제 안되도록 처리
return Response({'message': 'This item is folder.'}, status=status.HTTP_200_OK)
item.delete()
return Response({'message': 'delete permanently complete'}, status=status.HTTP_200_OK)
return Response({'message': 'item is not existed.'}, status=status.HTTP_204_NO_CONTENT)
# url: items/11/move
# 마지막 slash도 써주어야함
......
......@@ -30,7 +30,7 @@ urlpatterns = [
path('admin/', admin.site.urls),
path('', include(router.urls)),
url(r'^search/$', views.ItemViewSet.search, name='search'),
# url(r'^<int:pk>/delete/$', views.ItemViewSet.delete, name='delete'),
url(r'^<int:pk>/delete/$', views.ItemViewSet.delete, name='delete'),
url(r'^<int:pk>/restore/$', views.ItemViewSet.restore, name='restore'),
url(r'^<int:pk>/share/$', views.SharedItemViewSet.share, name='share'),
url(r'^<int:pk>/move/$', views.ItemViewSet.move, name='move'),
......