Add recursive printing for show_by_*

This commit is contained in:
Danny Robson 2020-06-09 13:17:55 +10:00
parent f11ad2c478
commit 8fa3551ed6

View File

@ -49,7 +49,7 @@ def add(session: sa.orm.Session, title: str, due: str = None, depends: List[int]
depends = []
obj = Task(title=title, due_at=due)
obj.depends.extend([session.query(Task).filter(Task.id == idx).one() for idx in depends])
obj.depends.extend(session.query(Task).filter(Task.id == idx).one() for idx in depends)
session.add(obj)
session.commit()
@ -72,6 +72,8 @@ def rm(session: sa.orm.Session, index: int):
# -----------------------------------------------------------------------------
def show_by_obj(session: sa.orm.Session, obj: Task):
for idx in [i.id for i in obj.depends]:
show_by_id(session, idx)
print(obj.id, obj.created_at, obj.due_at, obj.active, obj.title, [i.id for i in obj.depends])