home · contact · privacy
Require explicit call to Day.save to have any Day committed to DB.
[plomtask] / plomtask / days.py
index 02ad1a8f5223e1dbaee1ef445fd4e9b211ad4842..17bb46329760beb078a6497d68bd7b0a39a05e3e 100644 (file)
@@ -25,10 +25,9 @@ class Day:
         if not self.datetime:
             raise HandledException(f'Given date of wrong format: {self.date}')
 
-    @classmethod
-    def add(cls, db_conn: DatabaseConnection, date: str):
-        """Add (or re-write) new Day(date) to database."""
-        db_conn.exec('REPLACE INTO days VALUES (?)', (date,))
+    def save(self, db_conn: DatabaseConnection):
+        """Add (or re-write) self to database."""
+        db_conn.exec('REPLACE INTO days VALUES (?)', (self.date,))
 
     @classmethod
     def from_table_row(cls, row: Row):