From 5b8d054ed89ba41c6128aaaac57ee4e4900e08c6 Mon Sep 17 00:00:00 2001 From: William Peebles Date: Sun, 13 Nov 2022 23:09:56 -0500 Subject: [PATCH] delete tasks --- app.py | 9 ++++++++- templates/newtask.html | 2 +- templates/task.html | 7 ++++++- templates/tasks.html | 2 +- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app.py b/app.py index 1e775fe..adf08e9 100644 --- a/app.py +++ b/app.py @@ -77,4 +77,11 @@ def newTask(): @app.route('/task//') def task(task_id): task = Task.query.get_or_404(task_id) - return render_template('task.html', str=str, task=task, datetime=datetime, date=date) \ No newline at end of file + return render_template('task.html', str=str, task=task, datetime=datetime, date=date) + +@app.post('/task//delete') +def delete_task(task_id): + task = Task.query.get_or_404(task_id) + db.session.delete(task) + db.session.commit() + return redirect('/tasks') \ No newline at end of file diff --git a/templates/newtask.html b/templates/newtask.html index 5a36fa0..df52158 100644 --- a/templates/newtask.html +++ b/templates/newtask.html @@ -16,7 +16,7 @@ rows="5">

- +

{% endblock %} \ No newline at end of file diff --git a/templates/task.html b/templates/task.html index 0073f4b..eb1cc71 100644 --- a/templates/task.html +++ b/templates/task.html @@ -18,7 +18,12 @@

Due: {{ task.due_timestamp }}

-
+
+ +
{% endblock %} \ No newline at end of file diff --git a/templates/tasks.html b/templates/tasks.html index b95045b..7a31ca7 100644 --- a/templates/tasks.html +++ b/templates/tasks.html @@ -14,7 +14,7 @@ {{ task.description }}
-

Created: {{ createdTime }}

+

Created: {{ createdTime.strftime('%Y-%m-%d %I:%M %p') }}