Automated Action 5a02fb8b1f Implement comprehensive school portal API with FastAPI
- Complete authentication system with JWT and role-based access control
- User management for Admin, Teacher, Student, and Parent roles
- Student management with CRUD operations
- Class management and assignment system
- Subject and grade tracking functionality
- Daily attendance marking and viewing
- Notification system for announcements
- SQLite database with Alembic migrations
- Comprehensive API documentation with Swagger/ReDoc
- Proper project structure with services, models, and schemas
- Environment variable configuration
- CORS support and security features

🤖 Generated with BackendIM

Co-Authored-By: BackendIM <noreply@anthropic.com>
2025-06-25 13:31:56 +00:00

26 lines
1.1 KiB
Python

from sqlalchemy import Column, Integer, String, DateTime, Table, ForeignKey
from sqlalchemy.orm import relationship
from sqlalchemy.sql import func
from app.db.base import Base
teacher_classes = Table(
"teacher_classes",
Base.metadata,
Column("teacher_id", Integer, ForeignKey("users.id"), primary_key=True),
Column("class_id", Integer, ForeignKey("classes.id"), primary_key=True),
)
class Class(Base):
__tablename__ = "classes"
id = Column(Integer, primary_key=True, index=True)
name = Column(String, nullable=False)
grade_level = Column(String, nullable=False)
academic_year = Column(String, nullable=False)
created_at = Column(DateTime(timezone=True), server_default=func.now())
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
students = relationship("User", back_populates="assigned_class")
teachers = relationship("User", secondary=teacher_classes, back_populates="taught_classes")
subjects = relationship("Subject", back_populates="class_ref")
attendance_records = relationship("Attendance", back_populates="class_ref")