home · contact · privacy
Refactor .as_dict integration of Process.explicit_steps, Day.todos.
[plomtask] / plomtask / days.py
index 68cf989643924a42b1ef8b48cc04a63434efe6b9..92e44b2330b27caf7da9a3fce9ffca8aff3e7bc5 100644 (file)
@@ -12,6 +12,7 @@ class Day(BaseModel[str]):
     """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:
@@ -24,15 +25,6 @@ class Day(BaseModel[str]):
     def __lt__(self, other: Day) -> bool:
         return self.date < other.date
 
-    @property
-    def as_dict(self) -> dict[str, object]:
-        """Return self as (json.dumps-coompatible) dict."""
-        d = super().as_dict
-        assert isinstance(d['_library'], dict)
-        d['todos'] = [t.as_dict_into_reference(d['_library'])
-                      for t in self.todos]
-        return d
-
     @classmethod
     def from_table_row(cls, db_conn: DatabaseConnection, row: Row | list[Any]
                        ) -> Day: