to_save = ['is_active']
to_save_versioned = ['title', 'description']
to_search = ['title.newest', 'description.newest']
+ can_create_by_id = True
def __init__(self, id_: int | None, is_active: bool = False) -> None:
super().__init__(id_)
Checks for Todos and Processes that depend on Condition, prohibits
deletion if found.
"""
- if self.id_ is None:
- raise HandledException('cannot remove unsaved item')
- 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_):
- raise HandledException('cannot remove Condition in use')
+ 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)