home
·
contact
·
privacy
projects
/
plomtask
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove and shrink tests under redundancy with test utils defaults.
[plomtask]
/
plomtask
/
todos.py
diff --git
a/plomtask/todos.py
b/plomtask/todos.py
index fa009b12b8fb64e42b8a42f728fd0d4fb1740367..705bd725e2ff662ab4f9f2e370e61169a413ff03 100644
(file)
--- a/
plomtask/todos.py
+++ b/
plomtask/todos.py
@@
-1,7
+1,7
@@
"""Actionables."""
from __future__ import annotations
from dataclasses import dataclass
"""Actionables."""
from __future__ import annotations
from dataclasses import dataclass
-from typing import Any
+from typing import Any
, Set
from sqlite3 import Row
from plomtask.db import DatabaseConnection, BaseModel
from plomtask.processes import Process, ProcessStepsNode
from sqlite3 import Row
from plomtask.db import DatabaseConnection, BaseModel
from plomtask.processes import Process, ProcessStepsNode
@@
-34,6
+34,9
@@
class Todo(BaseModel[int], ConditionsRelations):
('todo_children', 'parent', 'children', 0),
('todo_children', 'child', 'parents', 1)]
to_search = ['comment']
('todo_children', 'parent', 'children', 0),
('todo_children', 'child', 'parents', 1)]
to_search = ['comment']
+ days_to_update: Set[str] = set()
+ children: list[Todo]
+ parents: list[Todo]
# pylint: disable=too-many-arguments
def __init__(self, id_: int | None,
# pylint: disable=too-many-arguments
def __init__(self, id_: int | None,
@@
-51,8
+54,8
@@
class Todo(BaseModel[int], ConditionsRelations):
self.date = valid_date(date)
self.comment = comment
self.effort = effort
self.date = valid_date(date)
self.comment = comment
self.effort = effort
- self.children
: list[Todo]
= []
- self.parents
: list[Todo]
= []
+ self.children = []
+ self.parents = []
self.calendarize = calendarize
if not self.id_:
self.calendarize = self.process.calendarize
self.calendarize = calendarize
if not self.id_:
self.calendarize = self.process.calendarize
@@
-129,11
+132,9
@@
class Todo(BaseModel[int], ConditionsRelations):
assert isinstance(todo.id_, int)
for t_id in db_conn.column_where('todo_children', 'child',
'parent', todo.id_):
assert isinstance(todo.id_, int)
for t_id in db_conn.column_where('todo_children', 'child',
'parent', todo.id_):
- # pylint: disable=no-member
todo.children += [cls.by_id(db_conn, t_id)]
for t_id in db_conn.column_where('todo_children', 'parent',
'child', todo.id_):
todo.children += [cls.by_id(db_conn, t_id)]
for t_id in db_conn.column_where('todo_children', 'parent',
'child', todo.id_):
- # pylint: disable=no-member
todo.parents += [cls.by_id(db_conn, t_id)]
for name in ('conditions', 'blockers', 'enables', 'disables'):
table = f'todo_{name}'
todo.parents += [cls.by_id(db_conn, t_id)]
for name in ('conditions', 'blockers', 'enables', 'disables'):
table = f'todo_{name}'
@@
-297,12
+298,17
@@
class Todo(BaseModel[int], ConditionsRelations):
if self.effort and self.effort < 0 and self.is_deletable:
self.remove(db_conn)
return
if self.effort and self.effort < 0 and self.is_deletable:
self.remove(db_conn)
return
+ if self.id_ is None:
+ self.__class__.days_to_update.add(self.date)
super().save(db_conn)
super().save(db_conn)
+ for condition in self.enables + self.disables + self.conditions:
+ condition.save(db_conn)
def remove(self, db_conn: DatabaseConnection) -> None:
"""Remove from DB, including relations."""
if not self.is_deletable:
raise HandledException('Cannot remove non-deletable Todo.')
def remove(self, db_conn: DatabaseConnection) -> None:
"""Remove from DB, including relations."""
if not self.is_deletable:
raise HandledException('Cannot remove non-deletable Todo.')
+ self.__class__.days_to_update.add(self.date)
children_to_remove = self.children[:]
parents_to_remove = self.parents[:]
for child in children_to_remove:
children_to_remove = self.children[:]
parents_to_remove = self.parents[:]
for child in children_to_remove: