diff --git a/app.py b/app.py index 0e4e836..6a38f5a 100644 --- a/app.py +++ b/app.py @@ -57,34 +57,7 @@ def delete_workout(person_id, workout_id): @ validate_workout def get_workout_start_date_edit_form(person_id, workout_id): workout = db.get_workout(person_id, workout_id) - return f""" -
-
- -
- -
- - - Update - - - Cancel - - """ + return render_template('partials/start_date.html', person_id=person_id, workout_id=workout_id, start_date=workout['StartDate'], is_edit=True) @ app.route("/person//workout//start_date", methods=['PUT']) @@ -92,35 +65,21 @@ def get_workout_start_date_edit_form(person_id, workout_id): def update_workout_start_date(person_id, workout_id): new_start_date = request.form.get('start-date') db.update_workout_start_date(workout_id, new_start_date) - return f""" - {new_start_date} - - Edit - - """ + return render_template('partials/start_date.html', person_id=person_id, workout_id=workout_id, start_date=new_start_date) @ app.route("/person//workout//start_date", methods=['GET']) @ validate_workout def get_workout_start_date(person_id, workout_id): workout = db.get_workout(person_id, workout_id) - return f""" - {workout['StartDate']} - - Edit - - """ + return render_template('partials/start_date.html', person_id=person_id, workout_id=workout_id, start_date=workout['StartDate']) @ app.route("/person//workout//topset/", methods=['GET']) @ validate_topset def get_topset(person_id, workout_id, topset_id): topset = db.get_topset(person_id, workout_id, topset_id) - return render_template('partials/person.html', topset=topset, exercises=exercises) + return render_template('partials/topset.html', person_id=person_id, workout_id=workout_id, topset_id=topset_id, exercise_name=topset['ExerciseName'], repetitions=topset['Repetitions'], weight=topset['Weight']) @ app.route("/person//workout//topset//edit_form", methods=['GET']) diff --git a/templates/partials/start_date.html b/templates/partials/start_date.html new file mode 100644 index 0000000..be5114d --- /dev/null +++ b/templates/partials/start_date.html @@ -0,0 +1,33 @@ +{% if is_edit|default(false, true) == false %} +{{ start_date }} + + Edit + +{% else %} +
+
+ +
+ +
+ + + Update + + + Cancel + +{% endif %} \ No newline at end of file diff --git a/templates/workout.html b/templates/workout.html index 035f42c..b11a521 100644 --- a/templates/workout.html +++ b/templates/workout.html @@ -18,12 +18,8 @@
- {{ workout['StartDate'] }} - - Edit - + {{ render_partial('partials/start_date.html', person_id=workout['PersonId'], workout_id=workout['WorkoutId'], + start_date=workout['StartDate']) }}