home
·
contact
·
privacy
projects
/
plomtask
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Overhaul as_dict generation to avoid endless nesting of objects.
[plomtask]
/
plomtask
/
days.py
diff --git
a/plomtask/days.py
b/plomtask/days.py
index 267156d831583d591788ad5a79bb6eb0013bdeaa..68cf989643924a42b1ef8b48cc04a63434efe6b9 100644
(file)
--- a/
plomtask/days.py
+++ b/
plomtask/days.py
@@
-28,7
+28,9
@@
class Day(BaseModel[str]):
def as_dict(self) -> dict[str, object]:
"""Return self as (json.dumps-coompatible) dict."""
d = super().as_dict
def as_dict(self) -> dict[str, object]:
"""Return self as (json.dumps-coompatible) dict."""
d = super().as_dict
- d['todos'] = [t.as_dict for t in self.todos]
+ assert isinstance(d['_library'], dict)
+ d['todos'] = [t.as_dict_into_reference(d['_library'])
+ for t in self.todos]
return d
@classmethod
return d
@classmethod
@@
-41,10
+43,9
@@
class Day(BaseModel[str]):
return day
@classmethod
return day
@classmethod
- def by_id(cls, db_conn: DatabaseConnection, id_: str
| None
) -> Day:
+ def by_id(cls, db_conn: DatabaseConnection, id_: str) -> Day:
"""Extend BaseModel.by_id checking for new/lost .todos."""
day = super().by_id(db_conn, id_)
"""Extend BaseModel.by_id checking for new/lost .todos."""
day = super().by_id(db_conn, id_)
- assert day.id_ is not None
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_)