From ceb76e7b1d75623b09a9c85a3e48752404a9077d Mon Sep 17 00:00:00 2001 From: stilbruch Date: Sat, 23 Apr 2022 17:08:53 -0500 Subject: Work on exercise type support for create workout --- app/tables/workout.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'app/tables') diff --git a/app/tables/workout.py b/app/tables/workout.py index cff0762..164f547 100644 --- a/app/tables/workout.py +++ b/app/tables/workout.py @@ -1,4 +1,9 @@ from app import db, login_manager +import enum + +class ExerciseType(enum.Enum): + TIME = "Seconds" + REPS = "Reps" # Represents an individual exercise class Exercise(db.Model): @@ -7,13 +12,15 @@ class Exercise(db.Model): name = db.Column(db.String(100), nullable=False) sets = db.Column(db.Integer) units = db.Column(db.Integer) + type = db.Column(db.Enum(ExerciseType)) # Workout Relationship workout_id = db.Column(db.Integer, db.ForeignKey('workouts.id')) - def __init__(self, name, sets, units): + def __init__(self, name, sets, units, type): self.name = name self.sets = sets - self.unit = units + self.units = units + self.type = type def __repr__(self): return f'' @@ -34,7 +41,8 @@ class Workout(db.Model): # Create exercises for exercise in exercises: - self.exercises.append(Exercise(exercise['name'], exercise['sets'], exercise['units'])) + type = ExerciseType.TIME if exercise['type'] == 'time'else ExerciseType.REPS; + self.exercises.append(Exercise(exercise['name'], exercise['sets'], exercise['units'], type)) def __repr__(self): return f'' -- cgit v1.2.3