summaryrefslogtreecommitdiff
path: root/app/tables
diff options
context:
space:
mode:
authorstilbruch <stilbruch@protonmail.com>2022-04-30 12:56:15 -0500
committerstilbruch <stilbruch@protonmail.com>2022-04-30 12:56:15 -0500
commit11ca7472f0736ed7f7cc4447f8fa59cd8765eb2f (patch)
tree0d8a360753d97077171d087fac131b5e50c6906b /app/tables
parent509a7bd8955138b2ff864dd75059d397b3fbb31e (diff)
downloadStrengthy-11ca7472f0736ed7f7cc4447f8fa59cd8765eb2f.tar.xz
Strengthy-11ca7472f0736ed7f7cc4447f8fa59cd8765eb2f.zip
Start workout history page
Diffstat (limited to 'app/tables')
-rw-r--r--app/tables/user.py1
-rw-r--r--app/tables/workout.py3
2 files changed, 4 insertions, 0 deletions
diff --git a/app/tables/user.py b/app/tables/user.py
index 483e56f..00457e6 100644
--- a/app/tables/user.py
+++ b/app/tables/user.py
@@ -19,6 +19,7 @@ class User(db.Model, UserMixin):
# relationships
workouts = db.relationship("Workout", backref="user", lazy="dynamic")
+ records = db.relationship("WorkoutRecord", backref="user", lazy="dynamic")
def __init__(self, username, password, email):
self.username = username
diff --git a/app/tables/workout.py b/app/tables/workout.py
index cc8478e..bdb200e 100644
--- a/app/tables/workout.py
+++ b/app/tables/workout.py
@@ -1,4 +1,5 @@
from app import db, login_manager
+from flask_login import current_user
import enum
@@ -84,6 +85,7 @@ class WorkoutRecord(db.Model):
finished = db.Column(db.DateTime)
# foreign keys
+ user_id = db.Column(db.Integer, db.ForeignKey("users.id"))
workout_id = db.Column(db.Integer, db.ForeignKey("workouts.id"))
# relationships
@@ -92,3 +94,4 @@ class WorkoutRecord(db.Model):
def __init__(self, workout, finished):
self.workout = workout
self.finished = finished
+ self.user = current_user