lots of work done, dashboards added
This commit is contained in:
+10
-12
@@ -11,7 +11,6 @@ from sqlalchemy.orm import relationship
|
||||
|
||||
from database import Base
|
||||
|
||||
|
||||
class User(Base):
|
||||
__tablename__ = "users"
|
||||
|
||||
@@ -19,7 +18,7 @@ class User(Base):
|
||||
username = Column(String, unique=True, nullable=False, index=True)
|
||||
password_hash = Column(String, nullable=False)
|
||||
display_name = Column(String, default="")
|
||||
role = Column(String, default="personal") # personal | trainer
|
||||
role = Column(String, default="personal")
|
||||
created_at = Column(String)
|
||||
|
||||
|
||||
@@ -32,7 +31,10 @@ class WorkoutType(Base):
|
||||
sort_order = Column(Integer, default=0)
|
||||
created_at = Column(String)
|
||||
|
||||
# ВАЖНО: Эта строка должна быть здесь!
|
||||
exercises = relationship("Exercise", back_populates="workout_type")
|
||||
|
||||
# Если есть другие отношения, они тоже должны быть прописаны
|
||||
workouts = relationship("Workout", back_populates="workout_type")
|
||||
|
||||
|
||||
@@ -42,20 +44,16 @@ class Exercise(Base):
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
sync_id = Column(String, unique=True, nullable=False, index=True)
|
||||
|
||||
# NULL = глобальный справочник, иначе — личное упражнение пользователя
|
||||
owner_id = Column(Integer, ForeignKey("users.id", ondelete="CASCADE"), index=True)
|
||||
|
||||
workout_type_id = Column(
|
||||
Integer,
|
||||
ForeignKey("workout_types.id", ondelete="SET NULL"),
|
||||
index=True,
|
||||
)
|
||||
workout_type_id = Column(Integer, ForeignKey("workout_types.id", ondelete="SET NULL"), index=True)
|
||||
|
||||
name = Column(String, nullable=False, index=True)
|
||||
created_at = Column(String)
|
||||
updated_at = Column(String)
|
||||
|
||||
# ВАЖНО: И эта строка тоже!
|
||||
workout_type = relationship("WorkoutType", back_populates="exercises")
|
||||
|
||||
workout_exercises = relationship("WorkoutExercise", back_populates="exercise")
|
||||
|
||||
|
||||
@@ -73,7 +71,7 @@ class Client(Base):
|
||||
color = Column(String)
|
||||
is_active = Column(Integer, default=1)
|
||||
|
||||
created_at = Column(String)
|
||||
created_at = Column(String, default=lambda: datetime.utcnow().isoformat())
|
||||
updated_at = Column(String)
|
||||
|
||||
workouts = relationship("Workout", back_populates="client")
|
||||
@@ -232,7 +230,7 @@ class MetricType(Base):
|
||||
unit = Column(String, default="см")
|
||||
category = Column(String, default="body")
|
||||
sort_order = Column(Integer, default=0)
|
||||
created_at = Column(String)
|
||||
created_at = Column(String, default=lambda: datetime.utcnow().isoformat())
|
||||
|
||||
metric_values = relationship("BodyMetricValue", back_populates="metric_type")
|
||||
|
||||
@@ -248,7 +246,7 @@ class BodyMetric(Base):
|
||||
|
||||
metric_date = Column(String, nullable=False)
|
||||
notes = Column(String, default="")
|
||||
created_at = Column(String)
|
||||
created_at = Column(String, default=lambda: datetime.utcnow().isoformat())
|
||||
|
||||
client = relationship("Client", back_populates="body_metrics")
|
||||
values = relationship(
|
||||
|
||||
Reference in New Issue
Block a user