Add basic workout tracking functionality, create/edit/delete workouts and there topsets

This commit is contained in:
Peter Stockings
2022-07-18 21:30:12 +10:00
parent 93ae1fa04b
commit 07f19b38c6
7 changed files with 403 additions and 367 deletions

232
app.py
View File

@@ -1,5 +1,6 @@
from flask import Flask, render_template, g, redirect, url_for
from flask import Flask, render_template, g, redirect, request, url_for
import sqlite3
import datetime
app = Flask(__name__)
@@ -17,34 +18,145 @@ def get_db():
def query_db(query, args=(), one=False):
cur = get_db().execute(query, args)
rv = cur.fetchall()
cur.connection.commit()
cur.close()
return (rv[0] if rv else None) if one else rv
@app.route("/")
def dashboard():
rows = query_db('select * from TopSet')
print(rows[0]['TopSetId'])
return render_template('index.html', name='peter')
return render_template('index.html')
@app.route("/person/<int:person_id>")
def display_workouts_for_person(person_id):
return render_template('workouts.html', person_id=person_id)
person = query_db('SELECT * FROM Person WHERE PersonId=?',
[person_id], one=True)
if person is None:
return render_template('error.html', error='404', message=f'Unable to find Person({person_id})', url='/')
workouts = query_db("""
SELECT
W.WorkoutId,
W.StartDate,
T.TopSetId,
E.ExcerciseId,
E.Name,
T.Repetitions || ' x ' || T.Weight || 'kg' AS TopSet
FROM
Workout W
LEFT JOIN TopSet T ON W.WorkoutId = T.WorkoutId
LEFT JOIN Excercise E ON T.ExcerciseId = E.ExcerciseId
WHERE
W.PersonId = ?""",
[person_id])
exercises = query_db('select * from Excercise')
unique_workout_ids = set([w['WorkoutId'] for w in workouts])
transformed_workouts = []
for workout_id in unique_workout_ids:
# topsets = [w for w in workouts if w['WorkoutId' == workout_id]]
topsets = []
for workout in workouts:
if workout['WorkoutId'] == workout_id:
topsets.append(workout)
topset_exercises = {}
for exercise in exercises:
for topset in topsets:
if topset['ExcerciseId'] == exercise['ExcerciseId']:
topset_exercises[exercise['ExcerciseId']
] = topset['TopSet']
workout = [w for w in workouts if w['WorkoutId'] == workout_id][0]
transformed_workouts.append(
{"workout_id": workout['WorkoutId'], "start_date": workout['StartDate'], "topset_exercises": topset_exercises})
return render_template('workouts.html', person_id=person_id, person=person, workouts=transformed_workouts, exercises=exercises)
@app.route("/person/<int:person_id>/new_workout")
def new_workout_for_person(person_id):
# 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))
person = query_db('SELECT * FROM Person WHERE PersonId=?',
[person_id], one=True)
if person is None:
return render_template('error.html', error='404', message=f'Unable to find Person({person_id})', url='/')
now = datetime.datetime.now()
date_string = now.strftime('%Y-%m-%d')
print(f'Creating workout for {person_id} at {date_string}')
query_db('INSERT INTO Workout (PersonId, StartDate) VALUES (?, ?)', [
person_id, date_string])
w = query_db('SELECT MAX(WorkoutId) AS WorkoutId FROM Workout WHERE PersonId=?', [
person_id], one=True)
return redirect(url_for('show_workout_for_person', person_id=person_id, workout_id=w['WorkoutId']))
@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)
workout_info = query_db("""
SELECT
P.Name,
W.StartDate
FROM
Person P
LEFT JOIN Workout W ON P.PersonId = W.PersonId
WHERE
P.PersonId = ?
AND W.WorkoutId = ?
LIMIT 1""",
[person_id, workout_id], one=True)
if workout_info is None:
return render_template('error.html', error='404', message=f'Unable to find Workout({workout_id}) completed by Person({person_id})', url=url_for('display_workouts_for_person', person_id=person_id))
top_sets = query_db("""
SELECT
T.TopSetId,
E.Name,
T.Repetitions || ' x ' || T.Weight || 'kg' AS TopSet
FROM
Person P
LEFT JOIN Workout W ON P.PersonId = W.PersonId
INNER JOIN TopSet T ON W.WorkoutId = T.WorkoutId
INNER JOIN Excercise E ON T.ExcerciseId = E.ExcerciseId
WHERE
P.PersonId = ?
AND W.WorkoutId = ?""",
[person_id, workout_id])
return render_template('workout.html', person_id=person_id, workout_id=workout_id, workout_info=workout_info, top_sets=top_sets, exercises=query_db('select * from Excercise'))
@app.route("/person/<int:person_id>/workout/<int:workout_id>/topset/<int:topset_id>")
@app.route("/person/<int:person_id>/workout/<int:workout_id>/delete", methods=['GET', 'DELETE'])
def delete_workout_from_person(person_id, workout_id):
workout_info = query_db("""
SELECT
P.Name,
W.StartDate
FROM
Person P
LEFT JOIN Workout W ON P.PersonId = W.PersonId
WHERE
P.PersonId = ?
AND W.WorkoutId = ?
LIMIT 1""",
[person_id, workout_id], one=True)
if workout_info is None:
return render_template('error.html', error='404', message=f'Unable to find Workout({workout_id}) completed by Person({person_id})', url=url_for('display_workouts_for_person', person_id=person_id))
query_db('DELETE FROM Workout WHERE WorkoutId=?',
[workout_id])
return redirect(url_for('display_workouts_for_person', person_id=person_id))
@app.route("/person/<int:person_id>/workout/<int:workout_id>/topset/<int:topset_id>", methods=['GET', 'POST'])
def show_topset_from_workout_for_person(person_id, workout_id, topset_id):
topset = query_db("""
SELECT
@@ -66,11 +178,111 @@ def show_topset_from_workout_for_person(person_id, workout_id, topset_id):
[person_id, workout_id, topset_id], one=True)
if topset is None:
return render_template('error.html', error='404', message=f'Unable to find TopSet({topset_id}) in Workout({workout_id}) completed by Person({person_id})')
return render_template('error.html', error='404', message=f'Unable to find TopSet({topset_id}) in Workout({workout_id}) completed by Person({person_id})', url=url_for('show_workout_for_person', person_id=person_id, workout_id=workout_id))
if request.method == 'POST':
exercise_id = request.form.get("exercise_id")
repetitions = request.form.get("repetitions")
weight = request.form.get("weight")
query_db('UPDATE TopSet SET ExcerciseId=?, Repetitions=?, Weight=? WHERE TopSetId=?', [
exercise_id, repetitions, weight, topset_id])
return redirect(url_for('show_workout_for_person', person_id=person_id, workout_id=workout_id))
return render_template('topset.html', topset=topset, exercises=query_db('select * from Excercise'))
@app.route("/person/<int:person_id>/workout/<int:workout_id>/topset", methods=['POST'])
def add_topset_to_workout_for_person(person_id, workout_id):
workout_info = query_db("""
SELECT
P.Name,
W.StartDate
FROM
Person P
LEFT JOIN Workout W ON P.PersonId = W.PersonId
WHERE
P.PersonId = ?
AND W.WorkoutId = ?
LIMIT 1""",
[person_id, workout_id], one=True)
if workout_info is None:
return render_template('error.html', error='404', message=f'Unable to find Workout({workout_id}) completed by Person({person_id})', url=url_for('display_workouts_for_person', person_id=person_id))
exercise_id = request.form.get("exercise_id")
repetitions = request.form.get("repetitions")
weight = request.form.get("weight")
query_db('INSERT INTO TopSet (WorkoutId, ExcerciseId, Repetitions, Weight) VALUES (?, ?, ?, ?)', [
workout_id, exercise_id, repetitions, weight])
return redirect(url_for('show_workout_for_person', person_id=person_id, workout_id=workout_id))
@app.route("/person/<int:person_id>/workout/<int:workout_id>/topset/<int:topset_id>/delete", methods=['GET', 'DELETE'])
def delete_topset_from_workout_for_person(person_id, workout_id, topset_id):
topset = query_db("""
SELECT
P.Name,
W.StartDate,
E.ExcerciseId,
E.Name,
T.Repetitions,
T.Weight
FROM
Person P
LEFT JOIN Workout W ON P.PersonId = W.PersonId
INNER JOIN TopSet T ON W.WorkoutId = T.WorkoutId
INNER JOIN Excercise E ON T.ExcerciseId = E.ExcerciseId
WHERE
P.PersonId = ?
AND W.WorkoutId = ?
AND T.TopSetId = ?""",
[person_id, workout_id, topset_id], one=True)
if topset is None:
return render_template('error.html', error='404', message=f'Unable to find TopSet({topset_id}) in Workout({workout_id}) completed by Person({person_id})', url=url_for('show_workout_for_person', person_id=person_id, workout_id=workout_id))
query_db('DELETE FROM TopSet WHERE TopSetId=?', [
topset_id])
return redirect(url_for('show_workout_for_person', person_id=person_id, workout_id=workout_id))
@app.context_processor
def my_utility_processor():
def is_selected_page(url):
if url == request.path:
return 'bg-gray-200'
return ''
def get_list_of_people_and_workout_count():
person_id = -1
if 'person_id' in request.view_args:
person_id = request.view_args['person_id']
return query_db("""
SELECT
P.PersonId,
P.Name,
COUNT(W.WorkoutId) AS NumberOfWorkouts,
CASE P.PersonId
WHEN ?
THEN 1
ELSE 0
END IsActive
FROM
Person P
LEFT JOIN Workout W ON P.PersonId = W.PersonId
GROUP BY
P.PersonId""", [person_id])
return dict(get_list_of_people_and_workout_count=get_list_of_people_and_workout_count, is_selected_page=is_selected_page)
@app.teardown_appcontext
def close_connection(exception):
db = getattr(g, '_database', None)

View File

@@ -57,10 +57,9 @@
<div class="flex-1 flex flex-col pt-5 pb-4 overflow-y-auto">
<div class="flex-1 px-3 bg-white divide-y space-y-1">
<ul class="space-y-2 pb-2">
<li>
<a href="{{ url_for('dashboard') }}"
class="text-base text-gray-900 font-normal rounded-lg flex items-center p-2 hover:bg-gray-100 group">
class="text-base text-gray-900 font-normal rounded-lg flex items-center p-2 hover:bg-gray-100 group {{ is_selected_page(url_for('dashboard')) }}">
<svg class="w-6 h-6 text-gray-500 group-hover:text-gray-900 transition duration-75"
fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
<path d="M2 10a8 8 0 018-8v8h8a8 8 0 11-16 0z"></path>
@@ -70,34 +69,24 @@
</a>
</li>
{% for p in get_list_of_people_and_workout_count() %}
<li>
<a href="{{ url_for('display_workouts_for_person' ,person_id=1) }}"
class="text-base text-gray-900 font-normal rounded-lg hover:bg-gray-100 flex items-center p-2 group ">
<a href="{{ url_for('display_workouts_for_person' ,person_id=p['PersonId']) }}"
class="text-base text-gray-900 font-normal rounded-lg hover:bg-gray-100 flex items-center p-2 group {% if p['IsActive']==1 %} bg-gray-200 {% endif %}">
<svg class="w-6 h-6 text-gray-500 flex-shrink-0 group-hover:text-gray-900 transition duration-75"
fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd"
d="M10 9a3 3 0 100-6 3 3 0 000 6zm-7 9a7 7 0 1114 0H3z" clip-rule="evenodd">
</path>
</svg>
<span class="ml-3 flex-1 whitespace-nowrap">Gabe</span>
<span class="ml-3 flex-1 whitespace-nowrap">{{ p['Name']}}</span>
<span
class="bg-gray-200 text-gray-800 ml-3 text-sm font-medium inline-flex items-center justify-center px-2 rounded-full">5</span>
</a>
</li>
<li>
<a href="{{ url_for('display_workouts_for_person' ,person_id=2) }}"
class="text-base text-gray-900 font-normal rounded-lg hover:bg-gray-100 flex items-center p-2 group ">
<svg class="w-6 h-6 text-gray-500 flex-shrink-0 group-hover:text-gray-900 transition duration-75"
fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd"
d="M10 9a3 3 0 100-6 3 3 0 000 6zm-7 9a7 7 0 1114 0H3z" clip-rule="evenodd">
</path>
</svg>
<span class="ml-3 flex-1 whitespace-nowrap">Michael</span>
<span
class="bg-gray-200 text-gray-800 ml-3 text-sm font-medium inline-flex items-center justify-center px-2 rounded-full">0</span>
class="bg-gray-200 text-gray-800 ml-3 text-sm font-medium inline-flex items-center justify-center px-2 rounded-full">{{
p['NumberOfWorkouts'] }}</span>
</a>
</li>
{% endfor %}
</ul>
<div class="space-y-2 pt-2">
<a href="https://github.com/themesberg/windster-tailwind-css-dashboard/issues"

View File

@@ -7,7 +7,7 @@
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative" role="alert">
<strong class="font-bold">Error: {{ error }}</strong>
<span class="block sm:inline">{{ message }}</span>
<a class="absolute top-0 bottom-0 right-0 px-4 py-3" href="/">
<a class="absolute top-0 bottom-0 right-0 px-4 py-3" href="{{ url }}">
<svg class="fill-current h-6 w-6 text-red-500" role="button" xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20">
<title>Close</title>

View File

@@ -2,13 +2,13 @@
{% block content %}
<div class="w-full grid grid-cols-1 xl:grid-cols-2 2xl:grid-cols-2 gap-4">
<div class="w-full grid grid-cols-1 xl:grid-cols-3 2xl:grid-cols-3 gap-4">
<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">List of rep maxes</span>
<span class="text-base font-normal text-gray-500">Current rep maxes</span>
</div>
<div class="flex-shrink-0">
<a href="{{ url_for('display_workouts_for_person' ,person_id=1) }}"
@@ -20,6 +20,7 @@
<div class="overflow-x-auto rounded-lg">
<div class="align-middle inline-block min-w-full">
<div class="shadow overflow-hidden sm:rounded-lg">
<h4 class="text-l font-semibold text-blue-400 mb-2 text-center">Bench</h4>
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
@@ -29,16 +30,11 @@
</th>
<th scope="col"
class="p-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Exercise
</th>
<th scope="col"
class="p-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Reps
Rep Max
</th>
<th scope="col"
class="p-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Weight
Estimated 1 Rep max
</th>
</tr>
</thead>
@@ -47,98 +43,118 @@
<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">
Squats
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5 x 100kg
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
100kg
130kg
</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">
Squats
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5 x 100kg
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
100kg
130kg
</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">
Squats
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5 x 100kg
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
100kg
130kg
</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">
Squats
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5 x 100kg
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5
130kg
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="flex flex-col mt-8">
<div class="overflow-x-auto rounded-lg">
<div class="align-middle inline-block min-w-full">
<div class="shadow overflow-hidden sm:rounded-lg">
<h4 class="text-l font-semibold text-blue-400 mb-2 text-center">Squat</h4>
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th scope="col"
class="p-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Date
</th>
<th scope="col"
class="p-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Rep Max
</th>
<th scope="col"
class="p-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Estimated 1 Rep max
</th>
</tr>
</thead>
<tbody class="bg-white">
<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-semibold text-gray-900">
100kg
5 x 100kg
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
130kg
</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">
Squats
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5 x 100kg
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
100kg
130kg
</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">
Squats
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5 x 100kg
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
100kg
130kg
</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">
Squats
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5 x 100kg
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
100kg
130kg
</td>
</tr>
</tbody>
@@ -154,7 +170,7 @@
<div class="mb-4 flex items-center justify-between">
<div>
<h3 class="text-xl font-bold text-gray-900 mb-2">Michael</h3>
<span class="text-base font-normal text-gray-500">List of rep maxes</span>
<span class="text-base font-normal text-gray-500">Current rep maxes</span>
</div>
<div class="flex-shrink-0">
<a href="{{ url_for('display_workouts_for_person' ,person_id=2) }}"
@@ -166,24 +182,21 @@
<div class="overflow-x-auto rounded-lg">
<div class="align-middle inline-block min-w-full">
<div class="shadow overflow-hidden sm:rounded-lg">
<h4 class="text-l font-semibold text-blue-400 mb-2 text-center">Bench</h4>
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th scope="col"
class="p-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Exercise
</th>
<th scope="col"
class="p-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Date
</th>
<th scope="col"
class="p-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Reps
Rep Max
</th>
<th scope="col"
class="p-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Weight
Estimated 1 Rep max
</th>
</tr>
</thead>
@@ -192,98 +205,118 @@
<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">
Squats
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5 x 100kg
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
100kg
130kg
</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">
Squats
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5 x 100kg
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
100kg
130kg
</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">
Squats
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5 x 100kg
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
100kg
130kg
</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">
Squats
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5 x 100kg
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5
130kg
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="flex flex-col mt-8">
<div class="overflow-x-auto rounded-lg">
<div class="align-middle inline-block min-w-full">
<div class="shadow overflow-hidden sm:rounded-lg">
<h4 class="text-l font-semibold text-blue-400 mb-2 text-center">Squat</h4>
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th scope="col"
class="p-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Date
</th>
<th scope="col"
class="p-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Rep Max
</th>
<th scope="col"
class="p-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Estimated 1 Rep max
</th>
</tr>
</thead>
<tbody class="bg-white">
<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-semibold text-gray-900">
100kg
5 x 100kg
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
130kg
</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">
Squats
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5 x 100kg
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
100kg
130kg
</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">
Squats
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5 x 100kg
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
100kg
130kg
</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">
Squats
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5 x 100kg
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
5
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
100kg
130kg
</td>
</tr>
</tbody>
@@ -293,6 +326,7 @@
</div>
</div>
</div>
</div>
<div class="mt-4 w-full grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4">

View File

@@ -28,7 +28,7 @@
<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">
id="grid-state" name="exercise_id">
{% for e in exercises %}
<option value="{{ e['ExcerciseId'] }}" {% if topset['ExcerciseId']==e['ExcerciseId'] %}
selected {% endif %}>{{
@@ -50,7 +50,7 @@
</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" value="{{ topset['Repetitions']}}">
id="grid-city" type="number" value="{{ topset['Repetitions']}}" name="repetitions">
</div>
<div class="w-full md:w-1/3 px-3 mb-6 md:mb-0">
@@ -59,7 +59,7 @@
</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" value="{{ topset['Weight']}}">
id="grid-zip" type="number" value="{{ topset['Weight']}}" name="weight">
</div>
</div>
<button

View File

@@ -6,8 +6,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>
<h3 class="text-xl font-bold text-gray-900 mb-2">{{ workout_info['Name'] }}</h3>
<span class="text-base font-normal text-gray-500">{{ workout_info['StartDate'] }}</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 workout
@@ -37,55 +37,25 @@
</tr>
</thead>
<tbody class="divide-y divide-gray-100">
{% for t in top_sets %}
<tr class="text-gray-500">
<th class="border-t-0 px-4 align-middle text-l 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">
{{ t['Name'] }}
</th>
<td class="border-t-0 px-4 align-middle text-l font-medium text-gray-900 whitespace-nowrap p-4">
5 x 60kg</td>
{{ t['TopSet'] }}</td>
<td class="border-t-0 px-4 align-middle text-xs whitespace-nowrap p-4">
<a href="{{ url_for('show_topset_from_workout_for_person' ,person_id=person_id, workout_id=workout_id, topset_id=1) }}"
<a href="{{ url_for('show_topset_from_workout_for_person', person_id=person_id, workout_id=workout_id, topset_id=t['TopSetId']) }}"
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 class="text-gray-500">
<th class="border-t-0 px-4 align-middle text-l font-normal whitespace-nowrap p-4 text-left">Bench
</th>
<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="{{ 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>
<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 class="text-gray-500">
<th class="border-t-0 px-4 align-middle text-l font-normal whitespace-nowrap p-4 text-left">Lat
Pulldowns
</th>
<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="{{ 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>
<a href="#"
<a href="{{ url_for('delete_topset_from_workout_for_person', person_id=person_id, workout_id=workout_id, topset_id=t['TopSetId'])}}"
class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2">
Delete
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
@@ -93,7 +63,9 @@
<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">
<form class="w-full max-w-lg"
action="{{ url_for('add_topset_to_workout_for_person', person_id=person_id, workout_id=workout_id) }}"
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">
@@ -103,10 +75,11 @@
<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>
id="grid-state" name="exercise_id">
{% for e in exercises %}
<option value="{{ e['ExcerciseId'] }}">{{
e['Name']}}</option>
{% endfor %}
</select>
<div
class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700">
@@ -123,7 +96,7 @@
</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">
id="grid-city" type="number" name="repetitions">
</div>
<div class="w-full md:w-1/3 px-3 mb-6 md:mb-0">
@@ -132,7 +105,7 @@
</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">
id="grid-zip" type="number" name="weight">
</div>
</div>
<button

View File

@@ -6,7 +6,7 @@
<div class="mb-4 flex items-center justify-between">
<div>
<h3 class="text-xl font-bold text-gray-900 mb-2">Gabe</h3>
<h3 class="text-xl font-bold text-gray-900 mb-2">{{ person['Name'] }}</h3>
<span class="text-base font-normal text-gray-500">List of workouts</span>
</div>
</div>
@@ -22,222 +22,50 @@
class="p-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Date
</th>
{% for e in exercises %}
<th scope="col"
class="p-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Squats
</th>
<th scope="col"
class="p-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Bench
</th>
<th scope="col"
class="p-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Deadlift
</th>
<th scope="col"
class="p-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Lat Pulldown
{{ e['Name'] }}
</th>
{% endfor %}
<th scope="col"
class="p-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider w-8">
</th>
</tr>
</thead>
<tbody class="bg-white">
{% for w in workouts %}
<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
{{ w['start_date'] }}
</td>
{% for e in exercises %}
<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
{% if e['ExcerciseId'] in w['topset_exercises'] %}
{{ w['topset_exercises'][e['ExcerciseId']] }}
{% endif %}
</td>
{% endfor %}
<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="{{ url_for('show_workout_for_person' ,person_id=person_id, workout_id=1) }}"
<a href="{{ url_for('show_workout_for_person' ,person_id=person_id, workout_id=w['workout_id']) }}"
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="{{ 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>
<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="{{ 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>
<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="{{ 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>
<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="{{ 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>
<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="{{ 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>
<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="{{ 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>
<a href="#"
<a href="{{ url_for('delete_workout_from_person', person_id=person_id, workout_id=w['workout_id'])}}"
class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2">
Delete
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<a href=" {{ url_for('new_workout_for_person', person_id=person_id) }}"
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">
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 mt-6">
New workout
</a>
</div>