Add route to display selected workout for a person

This commit is contained in:
Peter Stockings
2022-07-16 16:36:20 +10:00
parent 0356f6c817
commit 50231f5462
3 changed files with 135 additions and 68 deletions

10
app.py
View File

@@ -1,4 +1,4 @@
from flask import Flask, render_template, g from flask import Flask, render_template, g, redirect, url_for
import sqlite3 import sqlite3
app = Flask(__name__) app = Flask(__name__)
@@ -35,7 +35,13 @@ def display_workouts_for_person(person_id):
@app.route("/person/<int:person_id>/new_workout") @app.route("/person/<int:person_id>/new_workout")
def new_workout_for_person(person_id): 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/<int:person_id>/workout/<int:workout_id>")
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 @app.teardown_appcontext

View File

@@ -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"> 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</th> Top Set</th>
<th <th
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"> 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">
</th> </th>
</tr> </tr>
</thead> </thead>
<tbody class="divide-y divide-gray-100"> <tbody class="divide-y divide-gray-100">
<tr class="text-gray-500"> <tr class="text-gray-500">
<th class="border-t-0 px-4 align-middle text-sm font-normal whitespace-nowrap p-4 text-left">Squats <th class="border-t-0 px-4 align-middle text-l font-normal whitespace-nowrap p-4 text-left">Squats
</th> </th>
<td class="border-t-0 px-4 align-middle text-xs font-medium text-gray-900 whitespace-nowrap p-4"> <td class="border-t-0 px-4 align-middle text-l font-medium text-gray-900 whitespace-nowrap p-4">
5 x 60kg</td> 5 x 60kg</td>
<td class="border-t-0 px-4 align-middle text-xs whitespace-nowrap p-4"> <td class="border-t-0 px-4 align-middle text-xs whitespace-nowrap p-4">
<a href="#"
class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2">
Edit
</a>
<a href="#"
class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2">
Delete
</a>
</td> </td>
</tr> </tr>
<tr class="text-gray-500"> <tr class="text-gray-500">
<th class="border-t-0 px-4 align-middle text-sm font-normal whitespace-nowrap p-4 text-left">Squats <th class="border-t-0 px-4 align-middle text-l font-normal whitespace-nowrap p-4 text-left">Bench
</th> </th>
<td class="border-t-0 px-4 align-middle text-xs font-medium text-gray-900 whitespace-nowrap p-4"> <td class="border-t-0 px-4 align-middle text-l font-medium text-gray-900 whitespace-nowrap p-4">
5 x 60kg</td> 5 x 60kg</td>
<td class="border-t-0 px-4 align-middle text-xs whitespace-nowrap p-4"> <td class="border-t-0 px-4 align-middle text-xs whitespace-nowrap p-4">
<a href="#"
class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2">
Edit
</a>
<a href="#"
class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2">
Delete
</a>
</td> </td>
</tr> </tr>
<tr class="text-gray-500"> <tr class="text-gray-500">
<th class="border-t-0 px-4 align-middle text-sm font-normal whitespace-nowrap p-4 text-left">Squats <th class="border-t-0 px-4 align-middle text-l font-normal whitespace-nowrap p-4 text-left">Lat
Pulldowns
</th> </th>
<td class="border-t-0 px-4 align-middle text-xs font-medium text-gray-900 whitespace-nowrap p-4"> <td class="border-t-0 px-4 align-middle text-l font-medium text-gray-900 whitespace-nowrap p-4">
5 x 60kg</td>
<td class="border-t-0 px-4 align-middle text-xs whitespace-nowrap p-4">
</td>
</tr>
<tr class="text-gray-500">
<th class="border-t-0 px-4 align-middle text-sm font-normal whitespace-nowrap p-4 text-left">Squats
</th>
<td class="border-t-0 px-4 align-middle text-xs font-medium text-gray-900 whitespace-nowrap p-4">
5 x 60kg</td>
<td class="border-t-0 px-4 align-middle text-xs whitespace-nowrap p-4">
</td>
</tr>
<tr class="text-gray-500">
<th class="border-t-0 px-4 align-middle text-sm font-normal whitespace-nowrap p-4 text-left">Squats
</th>
<td class="border-t-0 px-4 align-middle text-xs font-medium text-gray-900 whitespace-nowrap p-4">
5 x 60kg</td>
<td class="border-t-0 px-4 align-middle text-xs whitespace-nowrap p-4">
</td>
</tr>
<tr class="text-gray-500">
<th class="border-t-0 px-4 align-middle text-sm font-normal whitespace-nowrap p-4 text-left">Squats
</th>
<td class="border-t-0 px-4 align-middle text-xs font-medium text-gray-900 whitespace-nowrap p-4">
5 x 60kg</td> 5 x 60kg</td>
<td class="border-t-0 px-4 align-middle text-xs whitespace-nowrap p-4"> <td class="border-t-0 px-4 align-middle text-xs whitespace-nowrap p-4">
<a href="#" <a href="#"

View File

@@ -39,6 +39,9 @@
class="p-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"> class="p-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Lat Pulldown Lat Pulldown
</th> </th>
<th scope="col"
class="p-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider w-8">
</th>
</tr> </tr>
</thead> </thead>
<tbody class="bg-white"> <tbody class="bg-white">
@@ -58,22 +61,15 @@
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900"> <td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5 x 60kg 5 x 60kg
</td> </td>
</tr>
<tr>
<td class="p-4 whitespace-nowrap text-sm font-normal text-gray-500">
Apr 23 ,2021
</td>
<td class="p-4 whitespace-nowrap text-sm font-normal text-gray-900">
5 x 60kg
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900"> <td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5 x 60kg <a href="#"
</td> class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2">
<td class="p-4 whitespace-nowrap text-sm font-normal text-gray-900"> Edit
5 x 60kg </a>
</td> <a href="#"
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900"> class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2">
5 x 60kg Delete
</a>
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -92,22 +88,15 @@
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900"> <td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5 x 60kg 5 x 60kg
</td> </td>
</tr>
<tr>
<td class="p-4 whitespace-nowrap text-sm font-normal text-gray-500">
Apr 23 ,2021
</td>
<td class="p-4 whitespace-nowrap text-sm font-normal text-gray-900">
5 x 60kg
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900"> <td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5 x 60kg <a href="#"
</td> class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2">
<td class="p-4 whitespace-nowrap text-sm font-normal text-gray-900"> Edit
5 x 60kg </a>
</td> <a href="#"
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900"> class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2">
5 x 60kg Delete
</a>
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -126,6 +115,16 @@
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900"> <td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5 x 60kg 5 x 60kg
</td> </td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
<a href="#"
class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2">
Edit
</a>
<a href="#"
class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2">
Delete
</a>
</td>
</tr> </tr>
<tr> <tr>
<td class="p-4 whitespace-nowrap text-sm font-normal text-gray-500"> <td class="p-4 whitespace-nowrap text-sm font-normal text-gray-500">
@@ -143,6 +142,16 @@
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900"> <td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5 x 60kg 5 x 60kg
</td> </td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
<a href="#"
class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2">
Edit
</a>
<a href="#"
class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2">
Delete
</a>
</td>
</tr> </tr>
<tr> <tr>
<td class="p-4 whitespace-nowrap text-sm font-normal text-gray-500"> <td class="p-4 whitespace-nowrap text-sm font-normal text-gray-500">
@@ -160,6 +169,70 @@
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900"> <td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5 x 60kg 5 x 60kg
</td> </td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
<a href="#"
class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2">
Edit
</a>
<a href="#"
class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2">
Delete
</a>
</td>
</tr>
<tr>
<td class="p-4 whitespace-nowrap text-sm font-normal text-gray-500">
Apr 23 ,2021
</td>
<td class="p-4 whitespace-nowrap text-sm font-normal text-gray-900">
5 x 60kg
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5 x 60kg
</td>
<td class="p-4 whitespace-nowrap text-sm font-normal text-gray-900">
5 x 60kg
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5 x 60kg
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
<a href="#"
class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2">
Edit
</a>
<a href="#"
class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2">
Delete
</a>
</td>
</tr>
<tr>
<td class="p-4 whitespace-nowrap text-sm font-normal text-gray-500">
Apr 23 ,2021
</td>
<td class="p-4 whitespace-nowrap text-sm font-normal text-gray-900">
5 x 60kg
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5 x 60kg
</td>
<td class="p-4 whitespace-nowrap text-sm font-normal text-gray-900">
5 x 60kg
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5 x 60kg
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
<a href="#"
class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2">
Edit
</a>
<a href="#"
class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2">
Delete
</a>
</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>