home · contact · privacy
Avoid confusing Day.by_id_or_create by always translating dating string first, so...
authorChristian Heller <c.heller@plomlompom.de>
Fri, 21 Jun 2024 16:26:04 +0000 (18:26 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Fri, 21 Jun 2024 16:26:04 +0000 (18:26 +0200)
plomtask/days.py

index 92e44b2330b27caf7da9a3fce9ffca8aff3e7bc5..7e6a5cce9177e2450107a111262482b8e5c23c3a 100644 (file)
@@ -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."""