Spaces:
Runtime error
Runtime error
| """ | |
| Practice Template model - Stores practice templates created by therapists | |
| """ | |
| from sqlalchemy import Column, Integer, String, JSON, DateTime, ForeignKey, Text | |
| from sqlalchemy.orm import relationship | |
| from sqlalchemy.sql import func | |
| from config.database import Base | |
| class PracticeTemplate(Base): | |
| __tablename__ = "practice_templates" | |
| id = Column(Integer, primary_key=True, index=True) | |
| # User association (therapist who created the template) | |
| user_id = Column(Integer, ForeignKey("users.id"), nullable=False) | |
| # Template details | |
| name = Column(String, nullable=False) | |
| practice_type = Column(String, nullable=False) # 'articulation-single-words', 'articulation-phrases', 'motor-chaining', 'reading', 'conversation' | |
| # Settings stored as JSON | |
| settings = Column(JSON, nullable=False) | |
| # Optional notes/description | |
| notes = Column(Text, nullable=True) | |
| # Usage tracking | |
| usage_count = Column(Integer, default=0) | |
| last_used = Column(DateTime(timezone=True), nullable=True) | |
| # Timestamps | |
| created_at = Column(DateTime(timezone=True), server_default=func.now()) | |
| updated_at = Column(DateTime(timezone=True), onupdate=func.now()) | |
| # Relationships | |
| user = relationship("User", backref="practice_templates") | |
| def __repr__(self): | |
| return f"<PracticeTemplate {self.name} (type: {self.practice_type})>" |