From 50231f5462de511e31653d9b3b57c81bbe16ab61 Mon Sep 17 00:00:00 2001 From: Peter Stockings Date: Sat, 16 Jul 2022 16:36:20 +1000 Subject: [PATCH] Add route to display selected workout for a person --- app.py | 10 +- templates/{new_workout.html => workout.html} | 60 ++++----- templates/workouts.html | 133 ++++++++++++++----- 3 files changed, 135 insertions(+), 68 deletions(-) rename templates/{new_workout.html => workout.html} (75%) diff --git a/app.py b/app.py index 75df870..8687f83 100644 --- a/app.py +++ b/app.py @@ -1,4 +1,4 @@ -from flask import Flask, render_template, g +from flask import Flask, render_template, g, redirect, url_for import sqlite3 app = Flask(__name__) @@ -35,7 +35,13 @@ def display_workouts_for_person(person_id): @app.route("/person//new_workout") def new_workout_for_person(person_id): - return render_template('new_workout.html', name='peter') + # hardcoded workout_id, need to create record in Workout table and return workout_id + return redirect(url_for('show_workout_for_person', person_id=person_id, workout_id=1)) + + +@app.route("/person//workout/") +def show_workout_for_person(person_id, workout_id): + return render_template('workout.html', person_id=person_id, workout_id=workout_id) @app.teardown_appcontext diff --git a/templates/new_workout.html b/templates/workout.html similarity index 75% rename from templates/new_workout.html rename to templates/workout.html index b91f259..c4667c5 100644 --- a/templates/new_workout.html +++ b/templates/workout.html @@ -32,60 +32,48 @@ class="px-4 bg-gray-50 text-gray-700 align-middle py-3 text-xs font-semibold text-left uppercase border-l-0 border-r-0 whitespace-nowrap"> Top Set + class="px-4 bg-gray-50 text-gray-700 align-middle py-3 text-xs font-semibold text-left uppercase border-l-0 border-r-0 whitespace-nowrap min-w-140-px w-8"> - Squats + Squats - + 5 x 60kg - + + Edit + + + Delete + - Squats + Bench - + 5 x 60kg - + + Edit + + + Delete + - Squats + Lat + Pulldowns - - 5 x 60kg - - - - - - Squats - - - 5 x 60kg - - - - - - Squats - - - 5 x 60kg - - - - - - Squats - - + 5 x 60kg Lat Pulldown + + @@ -58,22 +61,15 @@ 5 x 60kg - - - - Apr 23 ,2021 - - - 5 x 60kg - - 5 x 60kg - - - 5 x 60kg - - - 5 x 60kg + + Edit + + + Delete + @@ -92,22 +88,15 @@ 5 x 60kg - - - - Apr 23 ,2021 - - - 5 x 60kg - - 5 x 60kg - - - 5 x 60kg - - - 5 x 60kg + + Edit + + + Delete + @@ -126,6 +115,16 @@ 5 x 60kg + + + Edit + + + Delete + + @@ -143,6 +142,16 @@ 5 x 60kg + + + Edit + + + Delete + + @@ -160,6 +169,70 @@ 5 x 60kg + + + Edit + + + Delete + + + + + + Apr 23 ,2021 + + + 5 x 60kg + + + 5 x 60kg + + + 5 x 60kg + + + 5 x 60kg + + + + Edit + + + Delete + + + + + + Apr 23 ,2021 + + + 5 x 60kg + + + 5 x 60kg + + + 5 x 60kg + + + 5 x 60kg + + + + Edit + + + Delete + +