Beispiel #1
0
def create_task(sessionID, taskObj):
    task_class = task(sessionID)
    ret = task_class.createTask(taskObj)
    task_class.conn.close()
    if ret == -1:   return create_error("you must be logged in"), 401
    elif ret == -2: return create_error("internal error"), 500
    return create_result("new task added"), 200
Beispiel #2
0
def update_task(sessionID, taskID, taskObj):
    task_class = task(sessionID)
    ret = task_class.updateTaskById(taskID, taskObj)
    task_class.conn.close()
    if ret == -1:   return create_error("you must be logged in"), 401
    elif ret == -2: return create_error("internal error"), 500
    elif ret == -3: return create_error("task id does not exist"), 404
    return create_result("update done"), 200
Beispiel #3
0
def get_task(sessionID, taskID):
    task_class = task(sessionID)
    ret, tasks = task_class.getTaskById(taskID)
    task_class.conn.close()
    if ret == -1:   return create_error("you must be logged in"), 401
    elif ret == -2: return create_error("internal error"), 500
    elif ret == -3: return create_error("task id does not exist"), 404
    del tasks['task_id']
    return create_result(tasks), 200
Beispiel #4
0
def user_tasks(sessionID):
    task_class = task(sessionID)
    ret, tasks = task_class.getAllTasks()
    task_class.conn.close()
    if ret < 0:
        return ((create_error("you must be logged in"), 401) if ret == -1 else (create_error("internal error"), 500))
    new_tasks = []
    for _task in tasks:
        new_tasks.append({str(_task[0]): {
            "title": _task[1],
            "begin": _task[2],
            "end": _task[3],
            "status": _task[4]
        }})
    return create_result({"tasks": new_tasks}), 200