- def save(self, db_conn: DatabaseConnection) -> None:
- """Save self and its VersionedAttributes to DB and cache."""
- self.save_core(db_conn)
- self.title.save(db_conn)
- self.description.save(db_conn)
+ Checks for Todos and Processes that depend on Condition, prohibits
+ deletion if found.
+ """
+ if self.id_ is not None:
+ for item in ('process', 'todo'):
+ for attr in ('conditions', 'blockers', 'enables', 'disables'):
+ table_name = f'{item}_{attr}'
+ for _ in db_conn.row_where(table_name, 'condition',
+ self.id_):
+ msg = 'cannot remove Condition in use'
+ raise HandledException(msg)
+ super().remove(db_conn)