From d1f8adc797c3c6edd63b34d2da734783d9720138 Mon Sep 17 00:00:00 2001 From: FivePixels Date: Mon, 9 May 2022 16:43:19 -0500 Subject: Update records query to return all(), update footer on recent workouts to include number of recent workouts, programmatically add graphs to home page --- app/routes/basic.py | 1 + app/templates/home.html | 96 ++++++++++++++++++++++--------------------------- 2 files changed, 43 insertions(+), 54 deletions(-) (limited to 'app') diff --git a/app/routes/basic.py b/app/routes/basic.py index b211da7..bd5beb3 100644 --- a/app/routes/basic.py +++ b/app/routes/basic.py @@ -17,6 +17,7 @@ def home(): db.session.query(WorkoutRecord) .filter_by(user_id=current_user.id) .order_by(WorkoutRecord.finished.desc()) + .all() ) # Set records length diff --git a/app/templates/home.html b/app/templates/home.html index af365ad..e06e79b 100644 --- a/app/templates/home.html +++ b/app/templates/home.html @@ -9,8 +9,7 @@

Hello {{ current_user.username }}

-

- Welcome to your home. +

Welcome to your home.

@@ -20,12 +19,10 @@

{{ current_user.workouts.count() }}

-

Workouts

-
-
+

Workouts

-

{{ records.count() }}

+

{{ records|length }}

Workouts Completed

@@ -36,12 +33,12 @@ + -->
@@ -49,7 +46,7 @@

- My Workouts + My Workouts

@@ -57,34 +54,34 @@ {% for workout in current_user.workouts %} - - - - + + + + + + {% endfor %}
{{ workout.name }}{{ workout.exercises.count() }} exercises -

- Record - Edit - Delete +

{{ workout.name }}{{ workout.exercises.count() }} exercises +

+ Record + Edit + Delete +

+
@@ -99,7 +96,7 @@

- Recent Workouts + Recent Workouts

@@ -118,35 +115,26 @@
- View All +
+ {% for completed_workout in top3 %}
- -
-
-
-
- -
-
-
-
- +
+ {% endfor %}
{% endblock %} -- cgit v1.2.3 From 9ba45476efa21791c2c69a083d90785a436435f7 Mon Sep 17 00:00:00 2001 From: stilbruch Date: Mon, 9 May 2022 17:57:02 -0500 Subject: Fix float lbs bug --- app/forms/workout.py | 5 +++-- app/routes/workout.py | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/forms/workout.py b/app/forms/workout.py index f3a1082..a06c771 100644 --- a/app/forms/workout.py +++ b/app/forms/workout.py @@ -4,6 +4,7 @@ from wtforms import ( FormField, HiddenField, IntegerField, + FloatField, SelectField, StringField, ) @@ -14,7 +15,7 @@ class ExerciseCreateForm(Form): id = HiddenField("id", [Optional()]) name = StringField("name", [DataRequired()]) sets = IntegerField("sets", [DataRequired()]) - units = IntegerField("units", [DataRequired()]) + units = FloatField("units", [DataRequired()]) type = SelectField( "type", [DataRequired()], choices=[("reps", "Reps"), ("time", "Time")] ) @@ -27,7 +28,7 @@ class WorkoutCreateForm(FlaskForm): # /workout/record class SetForm(Form): - lbs = IntegerField("lbs", [Optional()]) + lbs = FloatField("lbs", [Optional()]) units = IntegerField("units", [Optional()]) diff --git a/app/routes/workout.py b/app/routes/workout.py index e27cee8..767603e 100644 --- a/app/routes/workout.py +++ b/app/routes/workout.py @@ -131,6 +131,7 @@ def workout_record(workout_id=None): return redirect(url_for("home")) else: + print(form.errors) # Populate form with data for exercise in workout.exercises: form.exercises.append_entry( -- cgit v1.2.3 From 99f2a95682b2acc03c595211a33cb1715abac429 Mon Sep 17 00:00:00 2001 From: stilbruch Date: Mon, 9 May 2022 17:59:40 -0500 Subject: Fix blank graph bug --- app/routes/basic.py | 1 + 1 file changed, 1 insertion(+) (limited to 'app') diff --git a/app/routes/basic.py b/app/routes/basic.py index bd5beb3..584d837 100644 --- a/app/routes/basic.py +++ b/app/routes/basic.py @@ -37,6 +37,7 @@ def home(): .filter(SetRecord.exercise_id == Exercise.id) .group_by(Exercise.id) .order_by(db.func.count(SetRecord.id).desc()) + .having(db.func.count(SetRecord.id) > 1) .limit(3) .all() ) -- cgit v1.2.3 From 083d5d904927e08bf365d74af504b14c6ad4a147 Mon Sep 17 00:00:00 2001 From: stilbruch Date: Mon, 9 May 2022 18:05:23 -0500 Subject: More bugs --- app/routes/api.py | 2 +- app/templates/home.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/routes/api.py b/app/routes/api.py index 77c8650..097400d 100644 --- a/app/routes/api.py +++ b/app/routes/api.py @@ -1,5 +1,5 @@ from app import app, db -from flask import redirect, request, jsonify +from flask import redirect, request, jsonify, url_for from flask_login import current_user, login_required from tables import Exercise, SetRecord, Workout, WorkoutRecord diff --git a/app/templates/home.html b/app/templates/home.html index e06e79b..bf22f67 100644 --- a/app/templates/home.html +++ b/app/templates/home.html @@ -134,7 +134,7 @@ {% endblock %} -- cgit v1.2.3