권주희

implement children post api

- folder 생성 api
...@@ -169,14 +169,18 @@ class ItemViewSet(viewsets.ViewSet): ...@@ -169,14 +169,18 @@ class ItemViewSet(viewsets.ViewSet):
169 res['list'] = children_list 169 res['list'] = children_list
170 return Response({'data': res}, status=status.HTTP_200_OK) 170 return Response({'data': res}, status=status.HTTP_200_OK)
171 if request.method == 'POST': 171 if request.method == 'POST':
172 - print("post") 172 + name = request.POST.get('name', '')
173 - # 173 + #TODO: user_id 수정해야
174 - # data = JSONParser().parse(request) 174 + item = Item(is_folder=True, name=name, file_type="folder", path="", parent=pk, user_id=1, size=0, status=True)
175 - # serializer = ItemSerializer(data=data) 175 + item.save()
176 - # if serializer.is_valid(): 176 + item = Item.objects.filter(item_id = item.item_id)
177 - # serializer.save() 177 + item_data = serializers.serialize("json", item)
178 - # return Response(serializer.data) 178 + json_item = json.loads(item_data)
179 - return Response({'message': 'post is not existed.'}, status=status.HTTP_204_NO_CONTENT) 179 + res = json_item[0]['fields']
180 + res['id']=json_item[0]['pk']
181 + res['inside_folder_list'] = []
182 + res['inside_file_list'] = []
183 + return Response({'data': res}, status=status.HTTP_200_OK)
180 184
181 185
182 class SharedItemViewSet(viewsets.ModelViewSet): 186 class SharedItemViewSet(viewsets.ModelViewSet):
......