Esempio n. 1
0
def perform_get_task(tid):
    """
    """
    task = data.get_task(tid)

    if not task:
        return json.dumps(_create_error("", "task not found", "Cannot find task with ID %s" % tid)), 404

    return json.dumps([task]), 200
Esempio n. 2
0
def perform_delete_task(tid):
    """
    """
    task = data.get_task(tid)

    if not task:
        return json.dumps(_create_error("", "task not found", "Cannot find task with ID %s" % tid)), 404

    data.delete_task(task)

    return "", 204
Esempio n. 3
0
def perform_update_task(tid, d):
    """
    """
    task = data.get_task(tid)

    if not task:
        return json.dumps(_create_error("", "task not found", "Cannot find task with ID %s" % tid)), 404

    if data.task_equals(task, d):
        return json.dumps(_create_error("", "No changes to modify the entity", "There are no attribute changes to modify the entity.")), 409

    task.update(d)

    error = _validate_task(task)
    if error:
        return json.dumps(error), 409

    return json.dumps([task]), 201