From 8bbbfecbf9962685a4c94de3d088dc3d7c95c035 Mon Sep 17 00:00:00 2001 From: Peter Stockings Date: Sat, 9 Dec 2023 16:23:04 +1100 Subject: [PATCH] More CamelCase refactoring, exercise functionality refactored --- app.py | 8 ++++---- db.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app.py b/app.py index 7498994..ebca410 100644 --- a/app.py +++ b/app.py @@ -211,7 +211,7 @@ def create_topset(person_id, workout_id): workout_id, exercise_id, repetitions, weight) exercise = db.get_exercise(exercise_id) - return render_template('partials/topset.html', person_id=person_id, workout_id=workout_id, topset_id=new_topset_id, exercise_id=exercise_id, exercise_name=exercise['Name'], repetitions=repetitions, weight=weight), 200, {"HX-Trigger": "topsetAdded"} + return render_template('partials/topset.html', person_id=person_id, workout_id=workout_id, topset_id=new_topset_id, exercise_id=exercise_id, exercise_name=exercise['name'], repetitions=repetitions, weight=weight), 200, {"HX-Trigger": "topsetAdded"} @ app.route("/person//workout//topset/", methods=['PUT']) @@ -224,7 +224,7 @@ def update_topset(person_id, workout_id, topset_id): db.update_topset(exercise_id, repetitions, weight, topset_id) exercise = db.get_exercise(exercise_id) - return render_template('partials/topset.html', person_id=person_id, workout_id=workout_id, topset_id=topset_id, exercise_name=exercise['Name'], repetitions=repetitions, weight=weight) + return render_template('partials/topset.html', person_id=person_id, workout_id=workout_id, topset_id=topset_id, exercise_name=exercise['name'], repetitions=repetitions, weight=weight) @ app.route("/person//workout//topset//delete", methods=['DELETE']) @@ -276,13 +276,13 @@ def create_exercise(): @ app.route("/exercise/", methods=['GET']) def get_exercise(exercise_id): exercise = db.get_exercise(exercise_id) - return render_template('partials/exercise.html', exercise_id=exercise_id, name=exercise['Name']) + return render_template('partials/exercise.html', exercise_id=exercise_id, name=exercise.name) @ app.route("/exercise//edit_form", methods=['GET']) def get_exercise_edit_form(exercise_id): exercise = db.get_exercise(exercise_id) - return render_template('partials/exercise.html', exercise_id=exercise_id, name=exercise['Name'], is_edit=True) + return render_template('partials/exercise.html', exercise_id=exercise_id, name=exercise.name, is_edit=True) @ app.route("/exercise//update", methods=['PUT']) diff --git a/db.py b/db.py index effc424..7d2d99a 100644 --- a/db.py +++ b/db.py @@ -54,7 +54,7 @@ class DataBase(): def get_exercise(self, exercise_id): exercise = self.execute( - 'SELECT exercise_id AS "ExerciseId", name AS "Name" FROM exercise WHERE exercise_id=%s LIMIT 1', [exercise_id], one=True) + 'SELECT exercise_id, name FROM exercise WHERE exercise_id=%s LIMIT 1', [exercise_id], one=True) return exercise def create_exercise(self, name): @@ -252,7 +252,7 @@ class DataBase(): 'PersonName': topset['PersonName'], 'WorkoutId': workout_id, 'StartDate': topset['StartDate'], - 'Exercises': self.get_exercises(), + 'Exercises': self.get_all_exercises(), "TopSetId": topset['TopSetId'], "ExerciseId": topset['ExerciseId'], "ExerciseName": topset['ExerciseName'],