home
·
contact
·
privacy
projects
/
plomtask
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Improve POST /day input validation.
[plomtask]
/
plomtask
/
processes.py
diff --git
a/plomtask/processes.py
b/plomtask/processes.py
index 6df8eaf9132d7652e447931d59a2cc6a39d3043b..36158996595dccfad678730eb29a50c422c26b9d 100644
(file)
--- a/
plomtask/processes.py
+++ b/
plomtask/processes.py
@@
-33,7
+33,9
@@
class Process(BaseModel[int], ConditionsRelations):
('process_disables', 'process', 'disables', 0),
('process_step_suppressions', 'process',
'suppressed_steps', 0)]
('process_disables', 'process', 'disables', 0),
('process_step_suppressions', 'process',
'suppressed_steps', 0)]
+ add_to_dict = ['explicit_steps']
to_search = ['title.newest', 'description.newest']
to_search = ['title.newest', 'description.newest']
+ can_create_by_id = True
def __init__(self, id_: int | None, calendarize: bool = False) -> None:
BaseModel.__init__(self, id_)
def __init__(self, id_: int | None, calendarize: bool = False) -> None:
BaseModel.__init__(self, id_)
@@
-46,24
+48,12
@@
class Process(BaseModel[int], ConditionsRelations):
self.calendarize = calendarize
self.n_owners: int | None = None # only set by from_table_row
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:
"""Make from DB row, with dependencies."""
process = super().from_table_row(db_conn, row)
@classmethod
def from_table_row(cls, db_conn: DatabaseConnection,
row: Row | list[Any]) -> Process:
"""Make from DB row, with dependencies."""
process = super().from_table_row(db_conn, row)
- assert isinstance(process.id_, int)
- for name in ('title', 'description', 'effort'):
- table = f'process_{name}s'
- for row_ in db_conn.row_where(table, 'parent', process.id_):
- getattr(process, name).history_from_row(row_)
+ assert process.id_ is not None
for name in ('conditions', 'blockers', 'enables', 'disables'):
table = f'process_{name}'
assert isinstance(process.id_, int)
for name in ('conditions', 'blockers', 'enables', 'disables'):
table = f'process_{name}'
assert isinstance(process.id_, int)