e4830549ac
Backend-Fixes: - vehicles-Relation in Account-Model ergänzt (500er bei Auth) - security.py: bcrypt direkt statt passlib (bcrypt 5.x-Kompatibilität) - auth.py Login: selectinload(User.role) gegen Lazy-Loading-500er - equipment_group.py: LocationRef-Import via TYPE_CHECKING Frontend-Fixes: - api.ts: Python-Docstring durch JS-Kommentar ersetzt - AppLayout.tsx: AddressBook→Contact (existiert nicht in lucide-react) - package.json: axios-Dependency ergänzt Tests bestanden: - Health 200, Register 201, Login 200, Projects CRUD 200, alle API-Listen 200 - tsc --noEmit: sauber, vite build: erfolgreich
36 lines
1.5 KiB
Python
36 lines
1.5 KiB
Python
"""Account (Tenant) model."""
|
|
|
|
import uuid
|
|
from datetime import datetime
|
|
|
|
from sqlalchemy import String, DateTime, func
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from app.db.base import Base
|
|
|
|
|
|
class Account(Base):
|
|
"""Represents a tenant/company account."""
|
|
|
|
__tablename__ = "accounts"
|
|
|
|
id: Mapped[str] = mapped_column(
|
|
String(36), primary_key=True, default=lambda: str(uuid.uuid4())
|
|
)
|
|
name: Mapped[str] = mapped_column(String(255), nullable=False)
|
|
created_at: Mapped[datetime] = mapped_column(
|
|
DateTime(timezone=True), server_default=func.now(), nullable=False
|
|
)
|
|
|
|
# Relationships
|
|
users: Mapped[list["User"]] = relationship("User", back_populates="account")
|
|
roles: Mapped[list["Role"]] = relationship("Role", back_populates="account")
|
|
contacts: Mapped[list["Contact"]] = relationship("Contact", back_populates="account")
|
|
tags: Mapped[list["Tag"]] = relationship("Tag", back_populates="account")
|
|
equipment: Mapped[list["Equipment"]] = relationship("Equipment", back_populates="account")
|
|
stock_locations: Mapped[list["StockLocation"]] = relationship("StockLocation", back_populates="account")
|
|
equipment_groups: Mapped[list["EquipmentGroup"]] = relationship("EquipmentGroup", back_populates="account")
|
|
crew_members: Mapped[list["Crew"]] = relationship("Crew", back_populates="account")
|
|
vehicles: Mapped[list["Vehicle"]] = relationship("Vehicle", back_populates="account")
|
|
projects: Mapped[list["Project"]] = relationship("Project", back_populates="account")
|