X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/decks/%7B%7Bdeck_id%7D%7D/cards/%7B%7Bcard_id%7D%7D/static/gitweb.js?a=blobdiff_plain;f=plomtask%2Fdays.py;fp=plomtask%2Fdays.py;h=7e6a5cce9177e2450107a111262482b8e5c23c3a;hb=ef4dfff9ff3002c11ccfef4190999a5e4e513606;hp=92e44b2330b27caf7da9a3fce9ffca8aff3e7bc5;hpb=c49e55023d5e9d91bcf1433fe893f574184efcb5;p=plomtask diff --git a/plomtask/days.py b/plomtask/days.py index 92e44b2..7e6a5cc 100644 --- a/plomtask/days.py +++ b/plomtask/days.py @@ -34,6 +34,13 @@ class Day(BaseModel[str]): day.todos = Todo.by_date(db_conn, day.id_) return day + @classmethod + def by_id_or_create(cls, db_conn: DatabaseConnection, id_: str | None + ) -> Day: + """Extend BaseModel.by_id to ensure date name translation.""" + assert isinstance(id_, str) + return super().by_id_or_create(db_conn, valid_date(id_)) + @classmethod def by_id(cls, db_conn: DatabaseConnection, id_: str) -> Day: """Extend BaseModel.by_id checking for new/lost .todos."""