示例#1
0
def add_task(action, user):
    """
    Adds a task.
    
    {
        'type': 'add_task',
        'listId': <list temporary id>,
        'what': <item>
    }
    """

    item = Item()
    item.description = action["what"].get("description", "")
    item.id = action["what"]["id"]
    item.position = action["what"]["position"]

    l = List.objects.get(id=action["listId"])
    verify_permission(l, user)

    l.items.append(item)
    l.save()

    return l