def createComment(request, task_id=None): created_time = datetime.datetime.now() request.data['time'] = created_time serializer = commentSerializer(data=request.data) if serializer.is_valid(): serializer.save() return Response(serializer.data, status=status.HTTP_201_CREATED) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
def commentList(request, task_id=None): if task_id: comments = Comment.objects.filter(mark=task_id) elif not task_id: comments = Comment.objects.all() else: return Response(status=status.HTTP_404_NOT_FOUND) serializer = commentSerializer(comments, many=True) return Response(serializer.data)
def createComment(request, task_id=None): serializer = commentSerializer(data=request.data) if serializer.is_valid(): serializer.save() return Response(serializer.data, status=status.HTTP_201_CREATED) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)