home · contact · privacy
Enable server to alternatively output response ctx as JSON, for debugging and testing...
[plomtask] / plomtask / days.py
index afe4a01be6f509a8b624da7c45650500a96805e2..a924bbfeadd2bd895d2f21ac4b7487305fbe771f 100644 (file)
@@ -23,6 +23,13 @@ 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
+        d['todos'] = [t.as_dict for t in self.todos]
+        return d
+
     @classmethod
     def from_table_row(cls, db_conn: DatabaseConnection, row: Row | list[Any]
                        ) -> Day: