Ejemplo n.º 1
0
def completed(request, task_id, start_time, end_time):
    """
    make user list with user's tasks sorted by priority
    """
    #returned task is now completed so mark it completed in the database
    completed_task = get_object_or_404(Task, pk=task_id)
    if completed_task.user == request.user:
        start_time = float(start_time)
        start_time = datetime.datetime.fromtimestamp(start_time/1000.0)
        time_started = Start_Time(time=start_time, task = completed_task)
        time_started.save()

        end_time = float(end_time)
        end_time = datetime.datetime.fromtimestamp(end_time/1000.0)
        time_end = End_Time(time=end_time, task = completed_task)
        time_end.save()
        Task.objects.filter(id=completed_task.pk).update(completed=True)




    user_tasks = Task.objects.filter(user=request.user, completed=False).order_by('-importance','enjoyment')
    quad_tasks = list()
    for i in range(0,5):
        empty = {
            'id': -1,
            'content': "empty",
            'complete_percentage': 0,
            'index': i
        }
        quad_tasks.append(empty)

    #make user list with user's tasks sorted by priority
    count = 0
    for task in user_tasks:
        quad_tasks[count]['id'] = task.pk
        quad_tasks[count]['content'] = task.content
        quad_tasks[count]['complete_percentage'] = task.complete_percentage
        quad_tasks[count]['index'] = count
        count+=1
        if count==5:
            break



    # return the id, content, and index of each tasks in the quad in a JSON response
    return HttpResponse(simplejson.dumps(quad_tasks), mimetype='application/json')
Ejemplo n.º 2
0
def time_up_from_listigain(request, task_id, start_time, end_time):
    """
    make user list with user's tasks sorted by priority
    """
    #returned task is now completed so mark it completed in the database
    completed_task = get_object_or_404(Task, pk=task_id)
    if completed_task.user == request.user:
        start_time = float(start_time)
        start_time = datetime.datetime.fromtimestamp(start_time/1000.0)
        time_started = Start_Time(time=start_time, task = completed_task)
        time_started.save()

        end_time = float(end_time)
        end_time = datetime.datetime.fromtimestamp(end_time/1000.0)
        time_end = End_Time(time=end_time, task = completed_task)
        time_end.save()
        return HttpResponseRedirect('/listigain/quad/time_up_break')
    else:
        return HttpResponseRedirect('/listigain/')