Add recursive printing for show_by_*
This commit is contained in:
parent
f11ad2c478
commit
8fa3551ed6
@ -49,7 +49,7 @@ def add(session: sa.orm.Session, title: str, due: str = None, depends: List[int]
|
|||||||
depends = []
|
depends = []
|
||||||
|
|
||||||
obj = Task(title=title, due_at=due)
|
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.add(obj)
|
||||||
|
|
||||||
session.commit()
|
session.commit()
|
||||||
@ -72,6 +72,8 @@ def rm(session: sa.orm.Session, index: int):
|
|||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
def show_by_obj(session: sa.orm.Session, obj: Task):
|
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])
|
print(obj.id, obj.created_at, obj.due_at, obj.active, obj.title, [i.id for i in obj.depends])
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user