summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/routes/workout.py33
-rw-r--r--app/templates/base/layout.html2
-rw-r--r--app/templates/home.html2
-rw-r--r--app/templates/workout/record_select.html (renamed from app/templates/workout/select.html)2
4 files changed, 16 insertions, 23 deletions
diff --git a/app/routes/workout.py b/app/routes/workout.py
index c8adc4e..de2fe51 100644
--- a/app/routes/workout.py
+++ b/app/routes/workout.py
@@ -92,18 +92,20 @@ def workout_edit():
return render_template("workout/create.html", form=form, workout=workout)
-@app.route("/workout/record", methods=["GET", "POST"])
+@app.route("/workout/record")
@login_required
-def workout_record():
- form = WorkoutRecordForm()
+def workout_record_select():
+ return render_template("workout/record_select.html")
- # Id is required
- if "id" not in request.args:
- return redirect(url_for("home"))
+
+@app.route("/workout/record/<workout_id>", methods=["GET", "POST"])
+@login_required
+def workout_record(workout_id=None):
+ form = WorkoutRecordForm()
# Matching workout required
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"))
@@ -142,22 +144,13 @@ def workout_record():
return render_template("workout/record.html", workout=workout, form=form)
-@app.route("/workout/select", methods=["GET"])
+@app.route("/workout/history/<record_id>")
@login_required
-def workout_select():
- return render_template("workout/select.html")
-
-
-@app.route("/workout/history", methods=["GET"])
-@login_required
-def workout_history():
- if "id" not in request.args:
- return redirect(url_for("home"))
-
- # Matching workout record required
+def workout_history(record_id=None):
record = WorkoutRecord.query.filter_by(
- id=int(request.args["id"]), user_id=current_user.id
+ id=int(record_id), user_id=current_user.id
).first()
+
if not record:
return redirect(url_for("home"))
diff --git a/app/templates/base/layout.html b/app/templates/base/layout.html
index 4da4f30..69b470d 100644
--- a/app/templates/base/layout.html
+++ b/app/templates/base/layout.html
@@ -47,7 +47,7 @@
</span>
<span class="navbar-item">
- <a class="button is-white is-outlined" href="/workout/select">
+ <a class="button is-white is-outlined" href="/workout/record">
<span class="icon">
<i class="fa fa-pencil"></i>
</span>
diff --git a/app/templates/home.html b/app/templates/home.html
index 235e6e7..397b54b 100644
--- a/app/templates/home.html
+++ b/app/templates/home.html
@@ -109,7 +109,7 @@
<tr>
<td>{{ record.workout.name }}</td>
<td>{{ record.finished.strftime("%m/%d/%y %-I:%M %p") }}</td>
- <td class="level-right"><a class="button is-small is-primary" href="/workout/history?id={{ record.id }}">View</a></td>
+ <td class="level-right"><a class="button is-small is-primary" href="/workout/history/{{ record.id }}">View</a></td>
</tr>
{% endfor %}
</tbody>
diff --git a/app/templates/workout/select.html b/app/templates/workout/record_select.html
index 7109c70..aeee3e2 100644
--- a/app/templates/workout/select.html
+++ b/app/templates/workout/record_select.html
@@ -14,7 +14,7 @@
{% for exercise in workout.exercises %}
<p>{{ exercise.sets }} x {{ exercise.units }} x {{ exercise.name }}</p>
{% endfor %}
- <a class="button" href="/workout/record?id={{ workout.id }}">Start</a>
+ <a class="button" href="/workout/record/{{ workout.id }}">Start</a>
</div>
</div>
</div>