begin edit task function
This commit is contained in:
8
app.py
8
app.py
@@ -79,6 +79,14 @@ 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)
|
||||
|
||||
@app.route('/task/<int:task_id>/edit', methods=('GET', 'POST'))
|
||||
def editTask(task_id):
|
||||
task = Task.query.get_or_404(task_id)
|
||||
if request.method == 'POST':
|
||||
task.title = request.form['title']
|
||||
task.description = request.form['description']
|
||||
db.session.commit()
|
||||
return render_template('edittask.html', str=str, task=task, datetime=datetime, date=date)
|
||||
@app.post('/task/<int:task_id>/delete')
|
||||
def delete_task(task_id):
|
||||
task = Task.query.get_or_404(task_id)
|
||||
|
22
templates/edittask.html
Normal file
22
templates/edittask.html
Normal file
@@ -0,0 +1,22 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<span><h1>{% block title %} Edit Task {% endblock %}</h1></span>
|
||||
<form method="post">
|
||||
<p>
|
||||
<label for="title">Title:</label><br>
|
||||
<input type="text" id="title" name="title"><br>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label for="description">Description</label><br>
|
||||
<textarea id="description"
|
||||
name="description"
|
||||
cols="25"
|
||||
rows="5"> </textarea>
|
||||
</p>
|
||||
<p>
|
||||
<button class="btn btn-primary" type="submit">Edit Task</button>
|
||||
</p>
|
||||
</form>
|
||||
{% endblock %}
|
Reference in New Issue
Block a user