add createProject(), fix a couple things
This commit is contained in:
parent
66f2ee7c17
commit
3cc8868699
19
DataStore.py
19
DataStore.py
@ -67,6 +67,20 @@ WHERE projectid = ?
|
||||
self.conn.commit()
|
||||
return tasks
|
||||
|
||||
def createProject(self, projectname):
|
||||
c = self.conn.cursor()
|
||||
projects = self.getProjects()
|
||||
if projectname in projects.values():
|
||||
return False
|
||||
nextid = self.getNextId('projects')
|
||||
c.execute('''
|
||||
INSERT INTO projects (id, name)
|
||||
VALUES (?, ?)
|
||||
''', (nextid, projectname))
|
||||
c.close()
|
||||
self.conn.commit()
|
||||
return True
|
||||
|
||||
def createTask(self, projectid, taskname):
|
||||
c = self.conn.cursor()
|
||||
tasks = self.getTasks(projectid)
|
||||
@ -75,7 +89,7 @@ WHERE projectid = ?
|
||||
nextid = self.getNextId('tasks')
|
||||
c.execute('''
|
||||
INSERT INTO tasks (id, projectid, name)
|
||||
VALUES (?, ?)
|
||||
VALUES (?, ?, ?)
|
||||
''', (nextid, projectid, taskname))
|
||||
c.close()
|
||||
self.conn.commit()
|
||||
@ -89,6 +103,7 @@ SELECT MAX(id)
|
||||
FROM %s
|
||||
''' % table)
|
||||
for row in c:
|
||||
nextid = row[0] + 1
|
||||
if row[0]:
|
||||
nextid = row[0] + 1
|
||||
c.close()
|
||||
return nextid
|
||||
|
Loading…
x
Reference in New Issue
Block a user