From a134f20eb62e6d174e7da81fd4adb7ff9e8b3b71 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 10 May 2020 11:07:12 +0200 Subject: Add task description field --- src/db/init.py | 1 + src/db/tasks.py | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'src/db') diff --git a/src/db/init.py b/src/db/init.py index c1835eb..cb8a4a8 100644 --- a/src/db/init.py +++ b/src/db/init.py @@ -12,6 +12,7 @@ def init(path): " created_at INTEGER NOT NULL," " modified_at INTEGER NOT NULL," " name TEXT NOT NULL," + " description TEXT," " duration INTEGER," " tag TEXT" " )") diff --git a/src/db/tasks.py b/src/db/tasks.py index d03877b..e22a315 100644 --- a/src/db/tasks.py +++ b/src/db/tasks.py @@ -10,6 +10,7 @@ def get(cursor: Cursor) -> Task: " created_at," " modified_at," " name," + " description," " duration," " tag" " FROM tasks") @@ -22,8 +23,9 @@ def get(cursor: Cursor) -> Task: created_at = task[1], modified_at = task[2], name = task[3], - duration = task[4], - tag = task[5] + description = task[4], + duration = task[5], + tag = task[6] )) return res @@ -35,16 +37,18 @@ def insert(cursor: Cursor, form: ValidTaskForm): " created_at," " modified_at," " name," + " description," " duration," " tag" - " ) VALUES (?, ?, ?, ?, ?)", - (now, now, form.name, form.duration, form.tag)) + " ) VALUES (?, ?, ?, ?, ?, ?)", + (now, now, form.name, form.description, form.duration, form.tag)) return Task( id = cursor.lastrowid, created_at = now, modified_at = now, name = form.name, + description = form.description, duration = form.duration, tag = form.tag ) @@ -57,16 +61,18 @@ def update(cursor: Cursor, task: Task, form: ValidTaskForm): " SET" " modified_at = ?," " name = ?," + " description = ?," " duration = ?," " tag = ?" " WHERE id = ?", - (now, form.name, form.duration, form.tag, task.id)) + (now, form.name, form.description, form.duration, form.tag, task.id)) return Task( id = task.id, created_at = task.created_at, modified_at = now, name = form.name, + description = form.description, duration = form.duration, tag = form.tag ) -- cgit v1.2.3