diff options
| author | stilbruch <stilbruch@protonmail.com> | 2022-04-23 17:08:53 -0500 |
|---|---|---|
| committer | stilbruch <stilbruch@protonmail.com> | 2022-04-23 17:08:53 -0500 |
| commit | ceb76e7b1d75623b09a9c85a3e48752404a9077d (patch) | |
| tree | ab2d93e62daad8d2b5a411e2cecc7fe3b73af448 /app/tables/workout.py | |
| parent | a4ca3d81f5bf0d00f1326ee80878da4169f54ea6 (diff) | |
| download | Strengthy-ceb76e7b1d75623b09a9c85a3e48752404a9077d.tar.xz Strengthy-ceb76e7b1d75623b09a9c85a3e48752404a9077d.zip | |
Work on exercise type support for create workout
Diffstat (limited to 'app/tables/workout.py')
| -rw-r--r-- | app/tables/workout.py | 14 |
1 files changed, 11 insertions, 3 deletions
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'<Exercise {self.name} {self.sets}x{self.units}>' @@ -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'<Workout {self.name}>' |
