diff --git a/app.py b/app.py index 2e87abe..715073f 100644 --- a/app.py +++ b/app.py @@ -47,6 +47,13 @@ def delete_workout(person_id, workout_id): return redirect(url_for('get_person', person_id=person_id)) +@ app.route("/person//workout/", methods=['POST']) +@ validate_workout +def update_workout(person_id, workout_id): + db.update_workout(workout_id, request.form) + return redirect(url_for('get_workout', person_id=person_id, workout_id=workout_id)) + + @ app.route("/person//workout//topset/", methods=['GET', 'POST']) @ validate_topset def get_topset(person_id, workout_id, topset_id): diff --git a/db.py b/db.py index 11245d7..4576627 100644 --- a/db.py +++ b/db.py @@ -124,6 +124,10 @@ class DataBase(): ORDER BY P.PersonId""", [person_id]) + def update_workout(self, workout_id, form): + self.execute('UPDATE Workout SET StartDate=%s WHERE WorkoutId=%s', [ + form.get('start-date'), workout_id], commit=True) + def get_person_final(self, person_id): topsets = self.execute(""" SELECT @@ -173,7 +177,7 @@ class DataBase(): 'PersonId': next((t['PersonId'] for t in topsets), -1), 'PersonName': next((t['PersonName'] for t in topsets), 'Unknown'), 'WorkoutId': workout_id, - 'StartDate': datetime.strptime(topsets[0]['StartDate'], "%Y-%m-%d").strftime("%b %d %Y"), + 'StartDate': datetime.strptime(topsets[0]['StartDate'], "%Y-%m-%d").strftime("%Y-%m-%d"), 'Exercises': self.get_exercises(), 'TopSets': [{"TopSetId": t['TopSetId'], "ExerciseId": t['ExerciseId'], "ExerciseName": t['ExerciseName'], "Weight": t['Weight'], "Repetitions": t['Repetitions']} for t in topsets if t['TopSetId'] is not None] } diff --git a/templates/workout.html b/templates/workout.html index 29b3b4b..99199c6 100644 --- a/templates/workout.html +++ b/templates/workout.html @@ -7,7 +7,28 @@

{{ workout['PersonName'] }}

- {{ workout['StartDate'] }} +
+
+
+ +
+ +
+ + +
+
@@ -118,7 +139,7 @@ + id="grid-zip" type="number" name="weight" step="any">