예제 #1
0
def delete(id: hug.types.number):
    """Delete the todo item by ID"""
    todo = session.query(ToDo).get(id)
    session.delete(todo)
    session.commit()
    if not session.query(ToDo).get(id):
        result = 'Success'
    else:
        result = 'Failure'
    return {'result': result}
예제 #2
0
def update(id: hug.types.number,
           todo: hug.types.text = None,
           assignee: hug.types.text = None,
           category: hug.types.text = None):
    """Delete the todo item by ID"""
    todo_db = session.query(ToDo).get(id)
    old_todo_db = todo_db.as_dict()
    if todo:
        todo_db.todo = todo
    if assignee:
        todo_db.assignee = assignee
    if category:
        todo_db.category = category
    todo_db.updated = datetime.utcnow()
    if not todo_db.as_dict() == old_todo_db:
        session.commit()
        return {'result': 'Success'}
    return {'result': 'No change'}
예제 #3
0
def all():
    """Get all items on the to do list"""
    todos = session.query(ToDo).all()
    return {'To Dos': [todo.as_dict() for todo in todos]}
예제 #4
0
def by_id(id: hug.types.number):
    """Get the todo item by ID"""
    todo = session.query(ToDo).get(id)
    return {'To Do': todo.as_dict()}
예제 #5
0
def all_by_assignee(assignee: hug.types.text):
    """Get all items on a to do list assigned to the given person"""
    todos = session.query(ToDo).filter_by(assignee=assignee).all()
    return {'To Dos': [todo.as_dict() for todo in todos]}
예제 #6
0
def all_by_category(category: hug.types.text):
    """Get all items in a category on a to do list"""
    todos = session.query(ToDo).filter_by(category=category).all()
    return {'To Dos': [todo.as_dict() for todo in todos]}