Improve look of SQL explorer page, and improve validation of exercise selection in workouts
This commit is contained in:
@@ -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}")
|
||||
|
||||
Reference in New Issue
Block a user