Exemplo n.º 1
0
def edit(
    id: str,
    db_engine: Engine,
    title: str = None,
    urgency: int = None,
    importance: int = None,
    tags: List[str] = None,
    anchor_folder: str = None,
    description: str = None,
):
    """Edit a task

    :param id: ID of the task to edit.
    :param db_engine: Engine for the tasks database.
    :param title: Update title of the task.
    :param urgency: Update urgency level[0-4] of the task.
    :param importance: Update importance level[0-4] of the task.
    :param tags: Set of tags to apply to the new task.
    :param anchor_folder: Anchor this task to a particular directory or file.
    :param description: Description of the task.
    """
    task: db.Task
    with db.session_scope(db_engine) as session:
        task = Query(db.Task, session).filter_by(id=id).one()
        if title:
            task.title = title
        if urgency:
            task.urgency = urgency
        if importance:
            task.importance = importance
        if tags:
            task.tags = tags
        if anchor_folder:
            task.folder = anchor_folder
        if description:
            task.description = description
        session.add(task)