home · contact · privacy
Minor refactorings.
[plomtask] / plomtask / days.py
index ba466b52c792f81029a94f4bc9fcc21718dd500b..89c957eef7ee49746e079d91ac3db3fa8d178760 100644 (file)
@@ -51,10 +51,13 @@ class Day:
         return days
 
     @classmethod
-    def by_date(cls, db_conn: DatabaseConnection, date: str):
+    def by_date(cls, db_conn: DatabaseConnection,
+                date: str, create: bool = False):
         """Retrieve Day by date if in DB, else return None."""
         for row in db_conn.exec('SELECT * FROM days WHERE date = ?', (date,)):
             return cls.from_table_row(row)
+        if create:
+            return cls(date)
         return None
 
     @property