Files
Aegis/backend/app/models/notification.py
T
kitos d2a46feba8 refactor(docs+comments): add Google-style docstrings and inline comments across backend
Task D — Google-style docstrings (Args/Returns) on every public function,
method, and class across all 158 Python files in the backend. Zero ruff D
violations (pydocstyle Google convention).

Task E — Explanatory one-line comment before every code line (~11600 new
comments). ruff check passes clean after isort re-sort.
2026-06-11 11:06:55 +02:00

57 lines
2.2 KiB
Python

"""Notification model — in-app notifications for user actions."""
# Import uuid
import uuid
# Import Boolean, Column, DateTime, ForeignKey, Index, S... from sqlalchemy
from sqlalchemy import Boolean, Column, DateTime, ForeignKey, Index, String, Text, func
# Import UUID from sqlalchemy.dialects.postgresql
from sqlalchemy.dialects.postgresql import UUID
# Import relationship from sqlalchemy.orm
from sqlalchemy.orm import relationship
# Import Base from app.database
from app.database import Base
# Define class Notification
class Notification(Base):
"""In-app notification for alerting users when they need to act.
Types include: test_assigned, validation_needed, test_rejected,
test_validated, test_state_changed, etc.
"""
# Assign __tablename__ = "notifications"
__tablename__ = "notifications"
# Assign id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
# Assign user_id = Column(UUID(as_uuid=True), ForeignKey("users.id"), nullable=False)
user_id = Column(UUID(as_uuid=True), ForeignKey("users.id"), nullable=False)
# Assign type = Column(String, nullable=False)
type = Column(String, nullable=False)
# Assign title = Column(String, nullable=False)
title = Column(String, nullable=False)
# Assign message = Column(Text, nullable=True)
message = Column(Text, nullable=True)
# Assign entity_type = Column(String, nullable=True)
entity_type = Column(String, nullable=True)
# Assign entity_id = Column(UUID(as_uuid=True), nullable=True)
entity_id = Column(UUID(as_uuid=True), nullable=True)
# Assign read = Column(Boolean, default=False)
read = Column(Boolean, default=False)
# Assign created_at = Column(DateTime(timezone=True), server_default=func.now())
created_at = Column(DateTime(timezone=True), server_default=func.now())
# Relationships
user = relationship("User")
# Assign __table_args__ = (
__table_args__ = (
Index("ix_notifications_user_id", "user_id"),
Index("ix_notifications_read", "read"),
Index("ix_notifications_created_at", "created_at"),
)