|
|
@ -22,7 +22,8 @@ app.config['SECRET KEY'] = 'this should be a secret random string'
|
|
|
|
@app.route('/')
|
|
|
|
@app.route('/')
|
|
|
|
def index():
|
|
|
|
def index():
|
|
|
|
conn = get_db_connection()
|
|
|
|
conn = get_db_connection()
|
|
|
|
todos = conn.execute('SELECT i.content, l.title FROM items i JOIN lists l \
|
|
|
|
todos = conn.execute('SELECT i.id, i.done, i.content, l.title \
|
|
|
|
|
|
|
|
FROM items i JOIN lists l \
|
|
|
|
ON i.list_id = l.id ORDER BY l.title;').fetchall()
|
|
|
|
ON i.list_id = l.id ORDER BY l.title;').fetchall()
|
|
|
|
|
|
|
|
|
|
|
|
lists = {}
|
|
|
|
lists = {}
|
|
|
@ -61,3 +62,19 @@ def create():
|
|
|
|
return render_template('create.html', lists=lists)
|
|
|
|
return render_template('create.html', lists=lists)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/<int:id>/do/', methods=('POST',))
|
|
|
|
|
|
|
|
def do(id):
|
|
|
|
|
|
|
|
conn = get_db_connection()
|
|
|
|
|
|
|
|
conn.execute('UPDATE items SET done = 1 WHERE id = ?', (id,))
|
|
|
|
|
|
|
|
conn.commit()
|
|
|
|
|
|
|
|
conn.close()
|
|
|
|
|
|
|
|
return redirect(url_for('index'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/<int:id>/undo/', methods=('POST',))
|
|
|
|
|
|
|
|
def undo(id):
|
|
|
|
|
|
|
|
conn = get_db_connection()
|
|
|
|
|
|
|
|
conn.execute('UPDATE items SET done = 0 WHERE id = ?', (id,))
|
|
|
|
|
|
|
|
conn.commit()
|
|
|
|
|
|
|
|
conn.close()
|
|
|
|
|
|
|
|
return redirect(url_for('index'))
|