X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=plomtask%2Fprocesses.py;fp=plomtask%2Fprocesses.py;h=6df8eaf9132d7652e447931d59a2cc6a39d3043b;hb=db62e6559fdd577dae38d4b6f5cbd5ef6a14cc57;hp=06ee4ba9b9c2a3011019b03b1b0e21633fce780c;hpb=a658d31f985ec9a08181005614c3d9876e046274;p=plomtask diff --git a/plomtask/processes.py b/plomtask/processes.py index 06ee4ba..6df8eaf 100644 --- a/plomtask/processes.py +++ b/plomtask/processes.py @@ -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: