Improve look of SQL explorer page, and improve validation of exercise selection in workouts

This commit is contained in:
Peter Stockings
2026-02-04 12:37:05 +11:00
parent 09d90b5a1e
commit 3f3725d277
8 changed files with 464 additions and 261 deletions

View File

@@ -226,6 +226,16 @@ def create_topset(person_id, workout_id):
exercise_id = request.form.get("exercise_id")
repetitions = request.form.get("repetitions")
weight = request.form.get("weight")
# Validation: Ensure exercise_id is present and is a valid integer
if not exercise_id or not exercise_id.strip():
return "Please select an exercise.", 400
try:
exercise_id = int(exercise_id)
except ValueError:
return "Invalid exercise selection.", 400
new_topset_id = db.create_topset(workout_id, exercise_id, repetitions, weight)
exercise = db.get_exercise(exercise_id)
db.activityRequest.log(current_user.id, 'ADD_SET', 'topset', new_topset_id, f"Added set: {repetitions} x {weight}kg {exercise['name']} in workout {workout_id}")