"""Individual days defined by their dates."""
table_name = 'days'
to_save = ['comment']
+ add_to_dict = ['todos']
can_create_by_id = True
def __init__(self, date: str, comment: str = '') -> None:
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
- assert isinstance(d['_library'], dict)
- d['todos'] = [t.as_dict_into_reference(d['_library'])
- for t in self.todos]
- return d
-
@classmethod
def from_table_row(cls, db_conn: DatabaseConnection, row: Row | list[Any]
) -> Day:
to_save: list[str] = []
to_save_versioned: list[str] = []
to_save_relations: list[tuple[str, str, str, int]] = []
+ add_to_dict: list[str] = []
id_: None | BaseModelId
cache_: dict[BaseModelId, Self]
to_search: list[str] = []
for rel in getattr(self, attr_name):
l += [rel.as_dict_into_reference(library)]
d[attr_name] = l
+ for k in self.add_to_dict:
+ d[k] = [x.as_dict_into_reference(library)
+ for x in getattr(self, k)]
return d
def as_dict_into_reference(self,
('process_disables', 'process', 'disables', 0),
('process_step_suppressions', 'process',
'suppressed_steps', 0)]
+ add_to_dict = ['explicit_steps']
to_search = ['title.newest', 'description.newest']
can_create_by_id = True
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
- assert isinstance(d['_library'], dict)
- d['explicit_steps'] = [s.as_dict_into_reference(d['_library'])
- for s in self.explicit_steps]
- return d
-
@classmethod
def from_table_row(cls, db_conn: DatabaseConnection,
row: Row | list[Any]) -> Process: