Added ability to delete.

This commit is contained in:
John Washam
2016-07-04 15:44:11 -07:00
parent 8796e1861a
commit d065628e25
3 changed files with 29 additions and 7 deletions

View File

@@ -110,7 +110,18 @@ def edit_card():
request.form['card_id']
])
db.commit()
flash('Card successfully edited.')
flash('Card saved.')
return redirect(url_for('cards'))
@app.route('/delete/<card_id>')
def delete(card_id):
if not session.get('logged_in'):
return redirect(url_for('login'))
db = get_db()
db.execute('DELETE FROM cards WHERE id = ?', [card_id])
db.commit()
flash('Card deleted.')
return redirect(url_for('cards'))