diff --git a/models/user.py b/models/user.py index faf81eb..cfca556 100644 --- a/models/user.py +++ b/models/user.py @@ -1,11 +1,30 @@ -from sqlalchemy import Column, String, Boolean +from sqlalchemy import Column, String, Integer, Boolean, DateTime, ForeignKey, Enum +from sqlalchemy.orm import relationship +from sqlalchemy.sql import func from core.database import Base +import uuid +from datetime import datetime class User(Base): __tablename__ = "users" - - id = Column(String, primary_key=True) - username = Column(String, unique=True, index=True) - email = Column(String, unique=True, index=True) - hashed_password = Column(String) - disabled = Column(Boolean, default=False) + + id = Column(String, primary_key=True, default=lambda: str(uuid.uuid4())) + first_name = Column(String(50), nullable=False) + last_name = Column(String(50), nullable=False) + email = Column(String(100), unique=True, nullable=False, index=True) + password = Column(String, nullable=False) + role = Column(Enum('student', 'teacher', 'admin', name='user_roles'), nullable=False) + phone_number = Column(String(20)) + address = Column(String(200)) + date_of_birth = Column(DateTime) + profile_picture = Column(String) + is_active = Column(Boolean, default=True) + last_login = Column(DateTime) + + created_at = Column(DateTime, default=func.now()) + updated_at = Column(DateTime, default=func.now(), onupdate=func.now()) + + courses = relationship("Course", secondary="user_courses", back_populates="users") + assignments = relationship("Assignment", back_populates="user") + grades = relationship("Grade", back_populates="user") + attendance = relationship("Attendance", back_populates="user") \ No newline at end of file