X-Git-Url: https://plomlompom.com/repos/berlin_corona.txt?a=blobdiff_plain;ds=sidebyside;f=plomtask%2Fprocesses.py;h=6df8eaf9132d7652e447931d59a2cc6a39d3043b;hb=ae757881abfe760e8a942a4d2f0667dd7fa0ac4b;hp=06ee4ba9b9c2a3011019b03b1b0e21633fce780c;hpb=c5449a0b00f8865b1129ed56bdd16f1cc055bc87;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: