diff options
Diffstat (limited to '')
-rw-r--r-- | item.py | 7 | ||||
-rw-r--r-- | storage/sqlite.py | 19 |
2 files changed, 19 insertions, 7 deletions
@@ -4,7 +4,7 @@ import time class item: readOnly = ['id'] - def __init__(self, title=None, created=None, priority=None, description=None, completed=None, removed=None, row=None): + def __init__(self, title=None, created=None, priority=None, description=None, completed=None, removed=None, due=None, row=None): self.__dict__['id'] = -1 if title != None: @@ -14,6 +14,7 @@ class item: self.description = description self.completed = completed self.removed = removed + self.due = due elif row != None: id = row[0] @@ -27,6 +28,7 @@ class item: self.description = '' self.completed = 0 self.removed = 0 + self.due = 0 def setId(self, id): if self.id == -1: @@ -53,6 +55,9 @@ class item: def getRemoved(self): return self.removed + def getDue(self): + return self.due + def __setattr__(self, name, value): if name not in item.readOnly: if name not in self.__dict__ or self.__dict__[name] != value: diff --git a/storage/sqlite.py b/storage/sqlite.py index 7a8e1d8..8c97186 100644 --- a/storage/sqlite.py +++ b/storage/sqlite.py @@ -6,7 +6,7 @@ from item import item from pysqlite2 import dbapi2 as sqliteBackend class sqlite(storageBase): - dbVersion = '0.4' + dbVersion = '0.5' def __init__(self): self.con = sqliteBackend.connect(self.getConfigDir() + '/data.sqlite') @@ -36,7 +36,8 @@ class sqlite(storageBase): priority INTEGER, desc BLOB, completed INTEGER(1) DEFAULT (0), - removed INTEGER(1) DEFAULT (0) + removed INTEGER(1) DEFAULT (0), + add due INTEGER DEFAULT (0) )''') self.cur.execute('drop table if exists control') @@ -69,6 +70,12 @@ class sqlite(storageBase): self.con.commit() updateFrom = ('0.4',) + if updateFrom == ('0.4',): + self.cur.execute('''alter table todo + add due INTEGER DEFAULT (0)''') + self.con.commit() + updateFrom = ('0.5',) + self.cur.execute("update control set value = ? where setting = 'db-version'", updateFrom) self.con.commit() @@ -85,13 +92,13 @@ class sqlite(storageBase): def notifyChange(self, sender): if sender.getId() >= 0: - self.cur.execute('update todo set title=?, createdAt=?, priority=?, desc=?, completed=?, removed=? where id=?', + self.cur.execute('update todo set title=?, createdAt=?, priority=?, desc=?, completed=?, removed=?, due=? where id=?', (sender.getTitle(), sender.getCreatedAt(), sender.getPriority(), - sender.getDescription(), sender.getCompleted(), sender.getRemoved(), sender.getId())) + sender.getDescription(), sender.getCompleted(), sender.getRemoved(), sender.getDue(), sender.getId())) self.con.commit() else: - self.cur.execute('insert into todo (title, createdAt, priority, desc, completed, removed) VALUES (?, ?, ?, ?, ?, ?)', + self.cur.execute('insert into todo (title, createdAt, priority, desc, completed, removed, due) VALUES (?, ?, ?, ?, ?, ?, ?)', (sender.getTitle(), sender.getCreatedAt(), sender.getPriority(), - sender.getDescription(), sender.getCompleted(), sender.getRemoved())) + sender.getDescription(), sender.getCompleted(), sender.getRemoved(), sender.getDue())) self.con.commit() sender.setId(self.cur.execute('select last_insert_rowid()').fetchone()[0]) |