Beispiel #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)
Beispiel #2
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)
Beispiel #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)
Beispiel #4
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)
Beispiel #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)
Beispiel #6
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)
Beispiel #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)
Beispiel #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)
Beispiel #9
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)