feat: Implement user-tenant relationship management with CRUD operations and access control
This commit is contained in:
@@ -3,11 +3,15 @@ Modelos ORM para gestión de tenants
|
||||
"""
|
||||
from sqlalchemy import Column, Integer, String, DateTime, Boolean, Text, Enum as SQLEnum
|
||||
from sqlalchemy.sql import func
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from datetime import datetime
|
||||
from typing import List, TYPE_CHECKING
|
||||
from core.database import Base
|
||||
import enum
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from api.v1.modules.a76.user_tenant.models import UserTenant
|
||||
|
||||
|
||||
class TenantType(enum.Enum):
|
||||
"""Tipo de tenant según tamaño y necesidades"""
|
||||
@@ -49,5 +53,8 @@ class Tenant(Base):
|
||||
updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=func.now(), onupdate=func.now())
|
||||
deleted_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
||||
|
||||
# Relación con UserTenant
|
||||
user_relations: Mapped[List["UserTenant"]] = relationship("UserTenant", back_populates="tenant")
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Tenant(id={self.id}, name={self.name}, type={self.type.value})>"
|
||||
|
||||
Reference in New Issue
Block a user