home
·
contact
·
privacy
projects
/
plomtask
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8c0cbef
)
Fix buggy Todo saving/removing.
author
Christian Heller
<c.heller@plomlompom.de>
Mon, 29 Apr 2024 02:58:32 +0000
(
04:58
+0200)
committer
Christian Heller
<c.heller@plomlompom.de>
Mon, 29 Apr 2024 02:58:32 +0000
(
04:58
+0200)
plomtask/todos.py
patch
|
blob
|
history
diff --git
a/plomtask/todos.py
b/plomtask/todos.py
index 3bd3491778d9c95c93bc34db8794c643e2069486..a874a6d7d6ba9a3596301ead4c4a024c3594748b 100644
(file)
--- a/
plomtask/todos.py
+++ b/
plomtask/todos.py
@@
-222,6
+222,8
@@
class Todo(BaseModel[int], ConditionsRelations):
raise NotFoundException('Process of Todo without ID (not saved?)')
self.save_core(db_conn)
assert isinstance(self.id_, int)
raise NotFoundException('Process of Todo without ID (not saved?)')
self.save_core(db_conn)
assert isinstance(self.id_, int)
+ db_conn.rewrite_relations('todo_children', 'child', self.id_,
+ [[p.id_] for p in self.parents])
db_conn.rewrite_relations('todo_children', 'parent', self.id_,
[[c.id_] for c in self.children])
db_conn.rewrite_relations('todo_conditions', 'todo', self.id_,
db_conn.rewrite_relations('todo_children', 'parent', self.id_,
[[c.id_] for c in self.children])
db_conn.rewrite_relations('todo_conditions', 'todo', self.id_,
@@
-234,10
+236,14
@@
class Todo(BaseModel[int], ConditionsRelations):
def remove(self, db_conn: DatabaseConnection) -> None:
"""Remove from DB, including relations."""
assert isinstance(self.id_, int)
def remove(self, db_conn: DatabaseConnection) -> None:
"""Remove from DB, including relations."""
assert isinstance(self.id_, int)
- for child in self.children:
+ children_to_remove = self.children[:]
+ parents_to_remove = self.parents[:]
+ for child in children_to_remove:
self.remove_child(child)
self.remove_child(child)
- for parent in
self.parents
:
+ for parent in
parents_to_remove
:
parent.remove_child(self)
parent.remove_child(self)
+ db_conn.delete_where('todo_children', 'parent', self.id_)
+ db_conn.delete_where('todo_children', 'child', self.id_)
db_conn.delete_where('todo_conditions', 'todo', self.id_)
db_conn.delete_where('todo_enables', 'todo', self.id_)
db_conn.delete_where('todo_disables', 'todo', self.id_)
db_conn.delete_where('todo_conditions', 'todo', self.id_)
db_conn.delete_where('todo_enables', 'todo', self.id_)
db_conn.delete_where('todo_disables', 'todo', self.id_)