Files
NuklearRabbit 04d26f1f2e M0: implement operational core
Backend: SQLAlchemy models, Alembic migrations, requirements lockfile. Frontend: pinned deps, package-lock, vite-env types fix. Verified compose build/health, pytest, ruff clean.
2026-08-01 21:01:04 +02:00

33 lines
1.4 KiB
Python

import uuid
from datetime import datetime
from sqlalchemy import Boolean, DateTime, ForeignKey, Integer, String, Text
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.orm import Mapped, mapped_column
from app.core.db import Base
from app.models.mixins import TimestampMixin, UUIDPrimaryKeyMixin
INSPECTION_TYPES = ("checkout", "return")
class Inspection(UUIDPrimaryKeyMixin, TimestampMixin, Base):
__tablename__ = "inspections"
public_ref: Mapped[str] = mapped_column(String(20), unique=True, nullable=False)
booking_id: Mapped[uuid.UUID] = mapped_column(
UUID(as_uuid=True), ForeignKey("bookings.id"), nullable=False
)
vehicle_id: Mapped[uuid.UUID] = mapped_column(
UUID(as_uuid=True), ForeignKey("vehicles.id"), nullable=False
)
type: Mapped[str] = mapped_column(String(20), nullable=False)
fuel_level_percent: Mapped[int] = mapped_column(Integer, nullable=False)
cleanliness_ok: Mapped[bool] = mapped_column(Boolean, nullable=False)
damage_reported: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
technical_warning: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
notes: Mapped[str | None] = mapped_column(Text)
odometer_km: Mapped[int] = mapped_column(Integer, nullable=False)
completed_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False)
completed_by: Mapped[str | None] = mapped_column(String(120))