row: Row | list[Any]) -> Condition:
"""Build condition from row, including VersionedAttributes."""
condition = super().from_table_row(db_conn, row)
- assert isinstance(condition, Condition)
for name in ('title', 'description'):
table_name = f'condition_{name}s'
for row_ in db_conn.row_where(table_name, 'parent', row[0]):
raise NotFoundException(f'Condition not found of id: {id_}')
condition = cls(id_, False)
condition.save(db_conn)
- assert isinstance(condition, Condition)
return condition
def save(self, db_conn: DatabaseConnection) -> None:
self.save_core(db_conn)
self.title.save(db_conn)
self.description.save(db_conn)
- assert isinstance(self.id_, int)
class ConditionsRelations:
"""Retrieve Day by date if in DB (prefer cache), else return None."""
day, _ = super()._by_id(db_conn, date)
if day:
- assert isinstance(day, Day)
return day
if not create:
raise NotFoundException(f'Day not found for date: {date}')
day = cls(date)
day.cache()
- assert isinstance(day, Day)
return day
@property
else:
for row in db_conn.row_where(cls.table_name, 'id', id_):
obj = cls.from_table_row(db_conn, row)
- assert isinstance(obj, cls)
obj.cache()
break
return obj, from_cache
process.set_enables(self.conn, self.form_data.get_all_int('enables'))
process.set_disables(self.conn, self.form_data.get_all_int('disables'))
process.save_core(self.conn)
- assert process.id_ is not None # for mypy
process.explicit_steps = []
steps: list[tuple[int | None, int, int | None]] = []
for step_id in self.form_data.get_all_int('steps'):
"""Retrieve ProcessStep by id_, or throw NotFoundException."""
step, _ = super()._by_id(db_conn, id_)
if step:
- assert isinstance(step, ProcessStep)
return step
raise NotFoundException(f'found no ProcessStep of ID {id_}')
'todo', todo.id_):
target = getattr(todo, name)
target += [Condition.by_id(db_conn, cond_id)]
- assert isinstance(todo, Todo)
return todo
@classmethod
if s.parent_step_id is None]
for child_process_id in [c.process.id_ for c in self.children]:
if child_process_id in unsatisfied:
- assert isinstance(child_process_id, int)
unsatisfied.remove(child_process_id)
return unsatisfied
and (c not in potentially_enabled)]:
children += [make_node(condition)]
else:
- assert isinstance(step, Condition)
seen = step.id_ in seen_conditions
seen_conditions.add(step.id_)
return TodoStepsNode(step, is_todo, children, seen)