home
·
contact
·
privacy
projects
/
plomtask
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Refactor .as_dict integration of Process.explicit_steps, Day.todos.
[plomtask]
/
plomtask
/
days.py
diff --git
a/plomtask/days.py
b/plomtask/days.py
index afe4a01be6f509a8b624da7c45650500a96805e2..92e44b2330b27caf7da9a3fce9ffca8aff3e7bc5 100644
(file)
--- a/
plomtask/days.py
+++ b/
plomtask/days.py
@@
-12,6
+12,8
@@
class Day(BaseModel[str]):
"""Individual days defined by their dates."""
table_name = 'days'
to_save = ['comment']
"""Individual days defined by their dates."""
table_name = 'days'
to_save = ['comment']
+ add_to_dict = ['todos']
+ can_create_by_id = True
def __init__(self, date: str, comment: str = '') -> None:
id_ = valid_date(date)
def __init__(self, date: str, comment: str = '') -> None:
id_ = valid_date(date)
@@
-33,13
+35,9
@@
class Day(BaseModel[str]):
return day
@classmethod
return day
@classmethod
- def by_id(cls,
- db_conn: DatabaseConnection, id_: str | None,
- create: bool = False,
- ) -> Day:
+ def by_id(cls, db_conn: DatabaseConnection, id_: str) -> Day:
"""Extend BaseModel.by_id checking for new/lost .todos."""
"""Extend BaseModel.by_id checking for new/lost .todos."""
- day = super().by_id(db_conn, id_, create)
- assert day.id_ is not None
+ day = super().by_id(db_conn, id_)
if day.id_ in Todo.days_to_update:
Todo.days_to_update.remove(day.id_)
day.todos = Todo.by_date(db_conn, day.id_)
if day.id_ in Todo.days_to_update:
Todo.days_to_update.remove(day.id_)
day.todos = Todo.by_date(db_conn, day.id_)