summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/routes/workout.py10
-rw-r--r--app/templates/home.html2
2 files changed, 4 insertions, 8 deletions
diff --git a/app/routes/workout.py b/app/routes/workout.py
index de2fe51..5eb18d9 100644
--- a/app/routes/workout.py
+++ b/app/routes/workout.py
@@ -32,16 +32,12 @@ def workout_create():
return render_template("workout/create.html", form=form)
-@app.route("/workout/edit", methods=["GET", "POST"])
+@app.route("/workout/edit/<workout_id>", methods=["GET", "POST"])
@login_required
-def workout_edit():
- # Id is required
- if "id" not in request.args:
- return redirect(url_for("home"))
-
+def workout_edit(workout_id=None):
# Validate Id
workout = Workout.query.filter_by(
- id=int(request.args["id"]), user_id=current_user.id
+ id=int(workout_id), user_id=current_user.id
).first()
if not workout:
return redirect(url_for("home"))
diff --git a/app/templates/home.html b/app/templates/home.html
index 397b54b..7ccacfd 100644
--- a/app/templates/home.html
+++ b/app/templates/home.html
@@ -62,7 +62,7 @@
<td>{{ workout.exercises.count() }} exercises</td>
<td class="level-right">
<p class="buttons">
- <a class="button is-small is-primary" href="/workout/edit?id={{ workout.id }}">Edit</a>
+ <a class="button is-small is-primary" href="/workout/edit/{{ workout.id }}">Edit</a>
<a class="button is-small is-danger js-modal-trigger" data-target="modal-{{ workout.id }}" href="#">Delete</a>
</p>
</td>