コード例 #1
0
def taskDetail(request, task_id):
    try:
        task = Task.objects.get(id=int(task_id))
    except Task.DoesNotExist:
        return Response(status=status.HTTP_404_NOT_FOUND)
    serializer = taskSerializer(task)
    return Response(serializer.data)
コード例 #2
0
ファイル: api.py プロジェクト: wangjun/AndwardTODO
def taskDetail(request, task_id):
    try:
        task = Task.objects.get(id=int(task_id))
    except Task.DoesNotExist:
        return Response(status=status.HTTP_404_NOT_FOUND)
    serializer = taskSerializer(task)
    return Response(serializer.data)
コード例 #3
0
def taskList(request, status_filter=None):
    if status_filter and status_filter in TASK_STATUS.keys():
        tasks = Task.objects.filter(status=TASK_STATUS[status_filter])
    elif not status_filter:
        tasks = Task.objects.all()
    else:
        return Response(status=status.HTTP_404_NOT_FOUND)
    serializer = taskSerializer(tasks, many=True)
    return Response(serializer.data)
コード例 #4
0
ファイル: api.py プロジェクト: wangjun/AndwardTODO
def taskList(request, status_filter=None):
    if status_filter and status_filter in TASK_STATUS.keys():
        tasks = Task.objects.filter(status=TASK_STATUS[status_filter])
    elif not status_filter:
        tasks = Task.objects.all()
    else:
        return Response(status=status.HTTP_404_NOT_FOUND)
    serializer = taskSerializer(tasks, many=True)
    return Response(serializer.data)
コード例 #5
0
def updateTask(request, task_id):
    try:
        task = Task.objects.get(id=int(task_id))
    except Task.DoesNotExist:
        return Response(status=status.HTTP_404_NOT_FOUND)
    serializer = taskSerializer(task, data=request.data)
    if serializer.is_valid():
        serializer.save()
        return Response(serializer.data)
    else:
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
コード例 #6
0
ファイル: api.py プロジェクト: wangjun/AndwardTODO
def updateTask(request, task_id):
    try:
        task = Task.objects.get(id=int(task_id))
    except Task.DoesNotExist:
        return Response(status=status.HTTP_404_NOT_FOUND)
    serializer = taskSerializer(task, data=request.data)
    if serializer.is_valid():
        serializer.save()
        return Response(serializer.data)
    else:
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
コード例 #7
0
def createTask(request, status_filter=None):
    created_time = datetime.datetime.now()
    request.data['time'] = created_time
    request.data['expiry'] = created_time
    request.data['status'] = 0
    request.data['expiry_status'] = 0
    serializer = taskSerializer(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)
コード例 #8
0
def createTask(request, status_filter=None):
    serializer = taskSerializer(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)
コード例 #9
0
ファイル: api.py プロジェクト: wangjun/AndwardTODO
def createTask(request, status_filter=None):
    serializer = taskSerializer(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)