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()
|
self.conn.commit()
|
||||||
return tasks
|
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):
|
def createTask(self, projectid, taskname):
|
||||||
c = self.conn.cursor()
|
c = self.conn.cursor()
|
||||||
tasks = self.getTasks(projectid)
|
tasks = self.getTasks(projectid)
|
||||||
@ -75,7 +89,7 @@ WHERE projectid = ?
|
|||||||
nextid = self.getNextId('tasks')
|
nextid = self.getNextId('tasks')
|
||||||
c.execute('''
|
c.execute('''
|
||||||
INSERT INTO tasks (id, projectid, name)
|
INSERT INTO tasks (id, projectid, name)
|
||||||
VALUES (?, ?)
|
VALUES (?, ?, ?)
|
||||||
''', (nextid, projectid, taskname))
|
''', (nextid, projectid, taskname))
|
||||||
c.close()
|
c.close()
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
@ -89,6 +103,7 @@ SELECT MAX(id)
|
|||||||
FROM %s
|
FROM %s
|
||||||
''' % table)
|
''' % table)
|
||||||
for row in c:
|
for row in c:
|
||||||
nextid = row[0] + 1
|
if row[0]:
|
||||||
|
nextid = row[0] + 1
|
||||||
c.close()
|
c.close()
|
||||||
return nextid
|
return nextid
|
||||||
|
Loading…
x
Reference in New Issue
Block a user