Add page/route to display selected topset from a workout for a person

This commit is contained in:
Peter Stockings
2022-07-16 16:47:28 +10:00
parent 50231f5462
commit 83841d6369
4 changed files with 91 additions and 20 deletions

5
app.py
View File

@@ -44,6 +44,11 @@ def show_workout_for_person(person_id, workout_id):
return render_template('workout.html', person_id=person_id, workout_id=workout_id)
@app.route("/person/<int:person_id>/workout/<int:workout_id>/topset/<int:topset_id>")
def show_topset_from_workout_for_person(person_id, workout_id, topset_id):
return render_template('topset.html', person_id=person_id, workout_id=workout_id, topset_id=topset_id)
@app.teardown_appcontext
def close_connection(exception):
db = getattr(g, '_database', None)

72
templates/topset.html Normal file
View File

@@ -0,0 +1,72 @@
{% extends 'base.html' %}
{% block content %}
<div class="bg-white shadow rounded-lg p-4 sm:p-6 xl:p-8 ">
<div class="mb-4 flex items-center justify-between">
<div>
<h3 class="text-xl font-bold text-gray-900 mb-2">Gabe</h3>
<span class="text-base font-normal text-gray-500">Apr 23 ,2021</span>
</div>
<a href="#" class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2">
Delete topset
</a>
</div>
</div>
<div class="bg-white shadow rounded-lg p-4 sm:p-6 xl:p-8 2xl:col-span-2 mt-4">
<div class=" ">
<form class="w-full max-w-lg" action="" method="post">
<div class="flex flex-wrap -mx-3 mb-2">
<div class="w-full md:w-1/3 px-3 mb-6 md:mb-0">
<label class="block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2" for="grid-state">
Exercise
</label>
<div class="relative">
<select
class="block appearance-none w-full bg-gray-200 border border-gray-200 text-gray-700 py-3 px-4 pr-8 rounded leading-tight focus:outline-none focus:bg-white focus:border-gray-500"
id="grid-state">
<option value="1">Squats</option>
<option value="2">Bench</option>
<option value="3">Deadlift</option>
</select>
<div
class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700">
<svg class="fill-current h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
<path d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z" />
</svg>
</div>
</div>
</div>
<div class="w-full md:w-1/3 px-3 mb-6 md:mb-0">
<label class="block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2" for="grid-city">
Reps
</label>
<input
class="appearance-none block w-full bg-gray-200 text-gray-700 border border-gray-200 rounded py-3 px-4 leading-tight focus:outline-none focus:bg-white focus:border-gray-500"
id="grid-city" type="number">
</div>
<div class="w-full md:w-1/3 px-3 mb-6 md:mb-0">
<label class="block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2" for="grid-zip">
Weight
</label>
<input
class="appearance-none block w-full bg-gray-200 text-gray-700 border border-gray-200 rounded py-3 px-4 leading-tight focus:outline-none focus:bg-white focus:border-gray-500"
id="grid-zip" type="number">
</div>
</div>
<button
class="sm:inline-flex text-white bg-cyan-600 hover:bg-cyan-700 focus:ring-4 focus:ring-cyan-200 font-medium rounded-lg text-sm px-5 py-2.5 text-center items-center"
type="submit">
Save top set
</button>
</form>
</div>
</div>
{% endblock %}

View File

@@ -43,7 +43,7 @@
<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">
<a href="#"
<a href="{{ url_for('show_topset_from_workout_for_person' ,person_id=person_id, workout_id=workout_id, topset_id=1) }}"
class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2">
Edit
</a>
@@ -59,7 +59,7 @@
<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">
<a href="#"
<a href="{{ url_for('show_topset_from_workout_for_person' ,person_id=person_id, workout_id=workout_id, topset_id=1) }}"
class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2">
Edit
</a>
@@ -76,7 +76,7 @@
<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">
<a href="#"
<a href="{{ url_for('show_topset_from_workout_for_person' ,person_id=person_id, workout_id=workout_id, topset_id=1) }}"
class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2">
Edit
</a>
@@ -135,7 +135,8 @@
id="grid-zip" type="number">
</div>
</div>
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 border border-blue-700 rounded"
<button
class="sm:inline-flex text-white bg-cyan-600 hover:bg-cyan-700 focus:ring-4 focus:ring-cyan-200 font-medium rounded-lg text-sm px-5 py-2.5 text-center items-center"
type="submit">
Add top set
</button>

View File

@@ -62,7 +62,7 @@
5 x 60kg
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
<a href="#"
<a href="{{ url_for('show_workout_for_person' ,person_id=person_id, workout_id=1) }}"
class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2">
Edit
</a>
@@ -89,7 +89,7 @@
5 x 60kg
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
<a href="#"
<a href="{{ url_for('show_workout_for_person' ,person_id=person_id, workout_id=1) }}"
class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2">
Edit
</a>
@@ -116,7 +116,7 @@
5 x 60kg
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
<a href="#"
<a href="{{ url_for('show_workout_for_person' ,person_id=person_id, workout_id=1) }}"
class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2">
Edit
</a>
@@ -143,7 +143,7 @@
5 x 60kg
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
<a href="#"
<a href="{{ url_for('show_workout_for_person' ,person_id=person_id, workout_id=1) }}"
class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2">
Edit
</a>
@@ -170,7 +170,7 @@
5 x 60kg
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
<a href="#"
<a href="{{ url_for('show_workout_for_person' ,person_id=person_id, workout_id=1) }}"
class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2">
Edit
</a>
@@ -197,7 +197,7 @@
5 x 60kg
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
<a href="#"
<a href="{{ url_for('show_workout_for_person' ,person_id=person_id, workout_id=1) }}"
class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2">
Edit
</a>
@@ -224,7 +224,7 @@
5 x 60kg
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
<a href="#"
<a href="{{ url_for('show_workout_for_person' ,person_id=person_id, workout_id=1) }}"
class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2">
Edit
</a>
@@ -237,15 +237,8 @@
</tbody>
</table>
<a href=" {{ url_for('new_workout_for_person', person_id=person_id) }}"
class="hidden sm:inline-flex ml-5 text-white bg-cyan-600 hover:bg-cyan-700 focus:ring-4 focus:ring-cyan-200 font-medium rounded-lg text-sm px-5 py-2.5 text-center items-center mr-3">
<svg class="svg-inline--fa fa-gem -ml-1 mr-2 h-4 w-4" aria-hidden="true" focusable="false"
data-prefix="fas" data-icon="gem" role="img" xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 512 512">
<path fill="currentColor"
d="M378.7 32H133.3L256 182.7L378.7 32zM512 192l-107.4-141.3L289.6 192H512zM107.4 50.67L0 192h222.4L107.4 50.67zM244.3 474.9C247.3 478.2 251.6 480 256 480s8.653-1.828 11.67-5.062L510.6 224H1.365L244.3 474.9z">
</path>
</svg>
Add workout
class="sm:inline-flex text-white bg-cyan-600 hover:bg-cyan-700 focus:ring-4 focus:ring-cyan-200 font-medium rounded-lg text-sm px-5 py-2.5 text-center items-center">
New workout
</a>
</div>
</div>