From 699390c28a8b8c766dca9e5d66a0af1a4b3cda76 Mon Sep 17 00:00:00 2001 From: Peter Stockings Date: Thu, 16 Mar 2023 23:09:37 +1100 Subject: [PATCH] Add ability to choose graphs to render, speed by default --- app.py | 7 +++++++ templates/users_and_workouts.html | 21 ++++++++++++++++++++- templates/workout_view.html | 21 +++++++++++++++++++++ templates/workouts_list.html | 11 +++++++---- 4 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 templates/workout_view.html diff --git a/app.py b/app.py index cca91ae..0cf03f0 100644 --- a/app.py +++ b/app.py @@ -157,6 +157,13 @@ def workout(user_id, workout_id, graph_type): return jsonify({'message': 'Workout {} not found for user {}.'.format(workout_id, user_id)}), 404 +@app.route('/user//workout//view', methods=['GET']) +def view_workout(user_id, workout_id): + workout = Workout.query.filter_by(user_id=user_id, id=workout_id).first() + graph_types = request.args.getlist('graph_types') + return render_template('workout_view.html', workout=workout, graph_types=graph_types) + + @app.route('/user//workout//delete', methods=['DELETE']) def delete_workout(user_io, workout_id): # Delete the workout and its associated cadence readings diff --git a/templates/users_and_workouts.html b/templates/users_and_workouts.html index bdb9bdb..8e74913 100644 --- a/templates/users_and_workouts.html +++ b/templates/users_and_workouts.html @@ -5,7 +5,24 @@ Cardio Tracker - + + + + @@ -49,6 +66,8 @@ + + \ No newline at end of file diff --git a/templates/workout_view.html b/templates/workout_view.html new file mode 100644 index 0000000..0005b60 --- /dev/null +++ b/templates/workout_view.html @@ -0,0 +1,21 @@ +
+
+ +
+
+ + +{% for graph_type in graph_types %} +No image +{% endfor %} \ No newline at end of file diff --git a/templates/workouts_list.html b/templates/workouts_list.html index d027378..c4ff3e0 100644 --- a/templates/workouts_list.html +++ b/templates/workouts_list.html @@ -19,16 +19,19 @@
+ +
+ {% with workout=w, graph_types=['speed'] %} + {% include 'workout_view.html' %} + {% endwith %} +