"""
Linux BenchTools - Location Models
"""

from sqlalchemy import Column, Integer, String, Text
from app.db.base import BasePeripherals


class Location(BasePeripherals):
    """
    Physical locations (rooms, closets, drawers, shelves)
    Hierarchical structure for organizing peripherals
    """
    __tablename__ = "locations"

    id = Column(Integer, primary_key=True, index=True)
    nom = Column(String(255), nullable=False, unique=True)
    type = Column(String(50), nullable=False, index=True)  # root, piece, placard, tiroir, etagere, meuble, boite
    parent_id = Column(Integer, index=True)  # Hierarchical relationship
    description = Column(Text)
    image_path = Column(String(500))  # Photo of the location
    qr_code_path = Column(String(500))  # QR code for quick access
    ordre_affichage = Column(Integer, default=0)

    def __repr__(self):
        return f"<Location(id={self.id}, nom='{self.nom}', type='{self.type}')>"
