Milestone 3
This commit is contained in:
37
backend/app/models/setting.py
Normal file
37
backend/app/models/setting.py
Normal file
@@ -0,0 +1,37 @@
|
||||
"""Platform settings (key/value JSONB) and admin-defined detection levels."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from sqlalchemy import Integer, String, Text
|
||||
from sqlalchemy.dialects.postgresql import JSONB
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from app.db.base import Base
|
||||
from app.db.mixins import TimestampMixin, UuidPkMixin
|
||||
|
||||
|
||||
class Setting(Base, TimestampMixin):
|
||||
__tablename__ = "settings"
|
||||
|
||||
key: Mapped[str] = mapped_column(String(80), primary_key=True)
|
||||
value: Mapped[Any] = mapped_column(JSONB, nullable=False)
|
||||
description: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
|
||||
|
||||
class DetectionLevel(Base, UuidPkMixin, TimestampMixin):
|
||||
"""Custom taxonomy admin can edit (cf. spec §F6).
|
||||
|
||||
Pre-seeded with detected_blocked / detected_alert / logged_only / not_detected.
|
||||
"""
|
||||
|
||||
__tablename__ = "detection_levels"
|
||||
|
||||
key: Mapped[str] = mapped_column(String(40), unique=True, nullable=False)
|
||||
label_fr: Mapped[str] = mapped_column(String(80), nullable=False)
|
||||
label_en: Mapped[str] = mapped_column(String(80), nullable=False)
|
||||
color_token: Mapped[str] = mapped_column(String(16), nullable=False)
|
||||
position: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
is_default: Mapped[bool] = mapped_column(default=False, nullable=False)
|
||||
is_system: Mapped[bool] = mapped_column(default=False, nullable=False)
|
||||
Reference in New Issue
Block a user