klg-asutk-app/backend/app/models/risk_alert.py
Yuriy aa052763f6 Безопасность и качество: 8 исправлений + обновления
- .env.example: полный шаблон, защита секретов
- .gitignore: явное исключение .env.* и секретов
- layout.tsx: XSS — заменён dangerouslySetInnerHTML на next/script для SW
- ESLint: no-console error (allow warn/error), ignore scripts/
- scripts/remove-console-logs.js: очистка console.log без glob
- backend/routes/modules: README с планом рефакторинга крупных файлов
- SECURITY.md: гид по секретам, XSS, CORS, auth, линту
- .husky/pre-commit: запуск npm run lint

+ прочие правки приложения и бэкенда

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-14 21:29:16 +03:00

30 lines
1.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from datetime import datetime, date
"""
Модель для автоматических предупреждений о рисках.
Заполняется сервисом risk_scanner по данным: ТО (сроки, next_due), LLP, шасси,
дефекты (limit_date), сертификаты лётной годности (expiry_date) и т.п.
"""
from sqlalchemy import String, DateTime, Text, Boolean
from sqlalchemy.orm import Mapped, mapped_column
from app.db.base import Base
from app.models.common import TimestampMixin, uuid4_str
class RiskAlert(Base, TimestampMixin):
__tablename__ = "risk_alerts"
id: Mapped[str] = mapped_column(String(36), primary_key=True, default=uuid4_str)
entity_type: Mapped[str] = mapped_column(String(64), nullable=False, index=True, doc="maintenance_task | limited_life | landing_gear | defect_report | airworthiness_certificate")
entity_id: Mapped[str] = mapped_column(String(36), nullable=False, index=True)
aircraft_id: Mapped[str | None] = mapped_column(String(36), nullable=True, index=True)
severity: Mapped[str] = mapped_column(String(32), nullable=False, default="medium", doc="low | medium | high | critical")
title: Mapped[str] = mapped_column(String(255), nullable=False)
message: Mapped[str | None] = mapped_column(Text, nullable=True)
due_at: Mapped[str | None] = mapped_column(DateTime(timezone=True), nullable=True)
is_resolved: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
resolved_at: Mapped[str | None] = mapped_column(DateTime(timezone=True), nullable=True)