add createProject(), fix a couple things

This commit is contained in:
Josh Holtrop 2011-02-15 22:18:41 -05:00
parent 66f2ee7c17
commit 3cc8868699

View File

@ -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