home · contact · privacy
Enable server to alternatively output response ctx as JSON, for debugging and testing...
[plomtask] / plomtask / processes.py
index 06ee4ba9b9c2a3011019b03b1b0e21633fce780c..6df8eaf9132d7652e447931d59a2cc6a39d3043b 100644 (file)
@@ -46,6 +46,14 @@ class Process(BaseModel[int], ConditionsRelations):
         self.calendarize = calendarize
         self.n_owners: int | None = None  # only set by from_table_row
 
+    @property
+    def as_dict(self) -> dict[str, object]:
+        """Return self as (json.dumps-coompatible) dict."""
+        d = super().as_dict
+        d['explicit_steps'] = [s.as_dict for s in self.explicit_steps]
+        d['suppressed_steps'] = [s.as_dict for s in self.suppressed_steps]
+        return d
+
     @classmethod
     def from_table_row(cls, db_conn: DatabaseConnection,
                        row: Row | list[Any]) -> Process:
@@ -218,7 +226,7 @@ class ProcessStep(BaseModel[int]):
         self.parent_step_id = parent_step_id
 
     def save(self, db_conn: DatabaseConnection) -> None:
-        """Remove from DB, and owner's .explicit_steps."""
+        """Update into DB/cache, and owner's .explicit_steps."""
         super().save(db_conn)
         owner = Process.by_id(db_conn, self.owner_id)
         if self not in owner.explicit_steps: