if child_id is not None:
child = Todo.by_id(conn, child_id)
todo.add_child(child)
- if len(form_data.get_all_str('done')) > 0:
- if not todo.is_doable:
- raise BadFormatException('cannot set undoable Todo to done')
- todo.is_done = True
- else:
- todo.is_done = False
+ todo.is_done = len(form_data.get_all_str('done')) > 0
todo.save(conn)
def do_POST_process(self, conn: DatabaseConnection, params: ParamsParser,
is_done: bool, day: Day) -> None:
self.id_ = id_
self.process = process
- self.is_done = is_done
+ self._is_done = is_done
self.day = day
self.children: list[Todo] = []
self.parents: list[Todo] = []
return False
return True
+ @property
+ def is_done(self) -> bool:
+ """Wrapper around self._is_done so we can control its setter."""
+ return self._is_done
+
+ @is_done.setter
+ def is_done(self, value: bool) -> None:
+ if value != self.is_done and not self.is_doable:
+ raise BadFormatException('cannot change doneness of undoable Todo')
+ self._is_done = value
+
def add_child(self, child: Todo) -> None:
"""Add child to self.children, guard against recursion"""
def walk_steps(node: Todo) -> None: