X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/move_up?a=blobdiff_plain;ds=sidebyside;f=plomtask%2Ftodos.py;h=43ada0b6a04f3df387c1f1933356e1e2b1832fbc;hb=aed1d5968abf97976db3725347fe4e7672c935e7;hp=e8e00acbd8cd77d58d7d99ce2d0551288ffb96f4;hpb=d77d0661697655a7c2d0e9e0b270cf21e286d7fb;p=plomtask diff --git a/plomtask/todos.py b/plomtask/todos.py index e8e00ac..43ada0b 100644 --- a/plomtask/todos.py +++ b/plomtask/todos.py @@ -25,7 +25,7 @@ class Todo: """Make Todo from database row, write to DB cache.""" todo = cls(id_=row[0], process=Process.by_id(db_conn, row[1]), - is_done=row[2], + is_done=bool(row[2]), day=Day.by_date(db_conn, row[3])) assert todo.id_ is not None db_conn.cached_todos[todo.id_] = todo @@ -61,6 +61,14 @@ class Todo: todos += [cls.by_id(db_conn, row[0])] return todos + @property + def is_doable(self) -> bool: + """Decide whether .is_done can be set to True based on children's.""" + for child in self.children: + if not child.is_done: + return False + return True + def add_child(self, child: Todo) -> None: """Add child to self.children, guard against recursion""" def walk_steps(node: Todo) -> None: