""" Organization model - represents a client company. """ from sqlalchemy import Boolean, String from sqlalchemy.orm import Mapped, mapped_column, relationship from app.models.base import Base class Organization(Base): """ Organization (client company) model. Each organization can have multiple users and devices. Products (WiFi, BLE) are enabled/disabled per organization. """ __tablename__ = "organizations" id: Mapped[int] = mapped_column(primary_key=True) name: Mapped[str] = mapped_column(String(255), nullable=False) contact_email: Mapped[str] = mapped_column(String(255), nullable=False) contact_phone: Mapped[str | None] = mapped_column(String(50)) # Product access (modular) wifi_enabled: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False) ble_enabled: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False) # Status: pending, active, suspended, deleted status: Mapped[str] = mapped_column( String(20), default="pending", nullable=False ) # Admin notes notes: Mapped[str | None] = mapped_column(String) # Relationships users: Mapped[list["User"]] = relationship( "User", back_populates="organization", cascade="all, delete-orphan" ) devices: Mapped[list["Device"]] = relationship( "Device", back_populates="organization" ) def __repr__(self) -> str: return f""