示例#1
0
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)
示例#2
0
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)
示例#3
0
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)
示例#4
0
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)