
- 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>
28 lines
1.3 KiB
Python
28 lines
1.3 KiB
Python
from sqlalchemy import Column, Integer, String, DateTime, ForeignKey, Boolean, Text, Table
|
|
from sqlalchemy.orm import relationship
|
|
from sqlalchemy.sql import func
|
|
from app.db.base import Base
|
|
|
|
notification_recipients = Table(
|
|
"notification_recipients",
|
|
Base.metadata,
|
|
Column("notification_id", Integer, ForeignKey("notifications.id"), primary_key=True),
|
|
Column("user_id", Integer, ForeignKey("users.id"), primary_key=True),
|
|
Column("is_read", Boolean, default=False),
|
|
Column("read_at", DateTime(timezone=True))
|
|
)
|
|
|
|
class Notification(Base):
|
|
__tablename__ = "notifications"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
title = Column(String, nullable=False)
|
|
message = Column(Text, nullable=False)
|
|
sender_id = Column(Integer, ForeignKey("users.id"), nullable=False)
|
|
notification_type = Column(String, nullable=False) # announcement, message, alert
|
|
priority = Column(String, default="normal") # low, normal, high, urgent
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
|
|
|
sender = relationship("User", foreign_keys=[sender_id], back_populates="sent_notifications")
|
|
recipients = relationship("User", secondary=notification_recipients, back_populates="received_notifications") |