From 116a7a47023ce18f7a54729f7da77eff674f8c0c Mon Sep 17 00:00:00 2001 From: stilbruch Date: Mon, 2 May 2022 17:43:02 -0500 Subject: Change workout/edit to parameterized route --- app/routes/workout.py | 10 +++------- app/templates/home.html | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) (limited to 'app') 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/", 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 @@ {{ workout.exercises.count() }} exercises

- Edit + Edit Delete

-- cgit v1.2.3