New enterprise feature
This commit is contained in:
@@ -46,8 +46,7 @@ structlog.configure(
|
||||
logger = structlog.get_logger()
|
||||
|
||||
# Fixed Demo Tenant IDs (must match seed_demo_tenants.py)
|
||||
DEMO_TENANT_SAN_PABLO = uuid.UUID("a1b2c3d4-e5f6-47a8-b9c0-d1e2f3a4b5c6")
|
||||
DEMO_TENANT_LA_ESPIGA = uuid.UUID("b2c3d4e5-f6a7-48b9-c0d1-e2f3a4b5c6d7")
|
||||
DEMO_TENANT_PROFESSIONAL = uuid.UUID("a1b2c3d4-e5f6-47a8-b9c0-d1e2f3a4b5c6")
|
||||
|
||||
# Owner user IDs (must match seed_demo_users.py)
|
||||
OWNER_SAN_PABLO = uuid.UUID("c1a2b3c4-d5e6-47a8-b9c0-d1e2f3a4b5c6") # María García López
|
||||
@@ -80,100 +79,100 @@ def get_permissions_for_role(role: str) -> str:
|
||||
TENANT_MEMBERS_DATA = [
|
||||
# San Pablo Members (Panadería Individual)
|
||||
{
|
||||
"tenant_id": DEMO_TENANT_SAN_PABLO,
|
||||
"tenant_id": DEMO_TENANT_PROFESSIONAL,
|
||||
"user_id": uuid.UUID("c1a2b3c4-d5e6-47a8-b9c0-d1e2f3a4b5c6"), # María García López
|
||||
"role": "owner",
|
||||
"invited_by": uuid.UUID("c1a2b3c4-d5e6-47a8-b9c0-d1e2f3a4b5c6"),
|
||||
"is_owner": True
|
||||
},
|
||||
{
|
||||
"tenant_id": DEMO_TENANT_SAN_PABLO,
|
||||
"tenant_id": DEMO_TENANT_PROFESSIONAL,
|
||||
"user_id": uuid.UUID("50000000-0000-0000-0000-000000000001"), # Juan Pérez Moreno - Panadero Senior
|
||||
"role": "baker",
|
||||
"invited_by": OWNER_SAN_PABLO,
|
||||
"is_owner": False
|
||||
},
|
||||
{
|
||||
"tenant_id": DEMO_TENANT_SAN_PABLO,
|
||||
"tenant_id": DEMO_TENANT_PROFESSIONAL,
|
||||
"user_id": uuid.UUID("50000000-0000-0000-0000-000000000002"), # Ana Rodríguez Sánchez - Responsable de Ventas
|
||||
"role": "sales",
|
||||
"invited_by": OWNER_SAN_PABLO,
|
||||
"is_owner": False
|
||||
},
|
||||
{
|
||||
"tenant_id": DEMO_TENANT_SAN_PABLO,
|
||||
"tenant_id": DEMO_TENANT_PROFESSIONAL,
|
||||
"user_id": uuid.UUID("50000000-0000-0000-0000-000000000003"), # Luis Fernández García - Inspector de Calidad
|
||||
"role": "quality_control",
|
||||
"invited_by": OWNER_SAN_PABLO,
|
||||
"is_owner": False
|
||||
},
|
||||
{
|
||||
"tenant_id": DEMO_TENANT_SAN_PABLO,
|
||||
"tenant_id": DEMO_TENANT_PROFESSIONAL,
|
||||
"user_id": uuid.UUID("50000000-0000-0000-0000-000000000004"), # Carmen López Martínez - Administradora
|
||||
"role": "admin",
|
||||
"invited_by": OWNER_SAN_PABLO,
|
||||
"is_owner": False
|
||||
},
|
||||
{
|
||||
"tenant_id": DEMO_TENANT_SAN_PABLO,
|
||||
"tenant_id": DEMO_TENANT_PROFESSIONAL,
|
||||
"user_id": uuid.UUID("50000000-0000-0000-0000-000000000005"), # Pedro González Torres - Encargado de Almacén
|
||||
"role": "warehouse",
|
||||
"invited_by": OWNER_SAN_PABLO,
|
||||
"is_owner": False
|
||||
},
|
||||
{
|
||||
"tenant_id": DEMO_TENANT_SAN_PABLO,
|
||||
"tenant_id": DEMO_TENANT_PROFESSIONAL,
|
||||
"user_id": uuid.UUID("50000000-0000-0000-0000-000000000006"), # Isabel Romero Díaz - Jefa de Producción
|
||||
"role": "production_manager",
|
||||
"invited_by": OWNER_SAN_PABLO,
|
||||
"is_owner": False
|
||||
},
|
||||
|
||||
# La Espiga Members (Obrador Central)
|
||||
# La Espiga Members (Professional Bakery - merged from San Pablo + La Espiga)
|
||||
{
|
||||
"tenant_id": DEMO_TENANT_LA_ESPIGA,
|
||||
"tenant_id": DEMO_TENANT_PROFESSIONAL,
|
||||
"user_id": uuid.UUID("d2e3f4a5-b6c7-48d9-e0f1-a2b3c4d5e6f7"), # Carlos Martínez Ruiz
|
||||
"role": "owner",
|
||||
"invited_by": uuid.UUID("d2e3f4a5-b6c7-48d9-e0f1-a2b3c4d5e6f7"),
|
||||
"is_owner": True
|
||||
},
|
||||
{
|
||||
"tenant_id": DEMO_TENANT_LA_ESPIGA,
|
||||
"tenant_id": DEMO_TENANT_PROFESSIONAL,
|
||||
"user_id": uuid.UUID("50000000-0000-0000-0000-000000000011"), # Roberto Sánchez Vargas - Director de Producción
|
||||
"role": "production_manager",
|
||||
"invited_by": OWNER_LA_ESPIGA,
|
||||
"is_owner": False
|
||||
},
|
||||
{
|
||||
"tenant_id": DEMO_TENANT_LA_ESPIGA,
|
||||
"tenant_id": DEMO_TENANT_PROFESSIONAL,
|
||||
"user_id": uuid.UUID("50000000-0000-0000-0000-000000000012"), # Sofía Jiménez Ortega - Responsable de Control de Calidad
|
||||
"role": "quality_control",
|
||||
"invited_by": OWNER_LA_ESPIGA,
|
||||
"is_owner": False
|
||||
},
|
||||
{
|
||||
"tenant_id": DEMO_TENANT_LA_ESPIGA,
|
||||
"tenant_id": DEMO_TENANT_PROFESSIONAL,
|
||||
"user_id": uuid.UUID("50000000-0000-0000-0000-000000000013"), # Miguel Herrera Castro - Coordinador de Logística
|
||||
"role": "logistics",
|
||||
"invited_by": OWNER_LA_ESPIGA,
|
||||
"is_owner": False
|
||||
},
|
||||
{
|
||||
"tenant_id": DEMO_TENANT_LA_ESPIGA,
|
||||
"tenant_id": DEMO_TENANT_PROFESSIONAL,
|
||||
"user_id": uuid.UUID("50000000-0000-0000-0000-000000000014"), # Elena Morales Ruiz - Directora Comercial
|
||||
"role": "sales",
|
||||
"invited_by": OWNER_LA_ESPIGA,
|
||||
"is_owner": False
|
||||
},
|
||||
{
|
||||
"tenant_id": DEMO_TENANT_LA_ESPIGA,
|
||||
"tenant_id": DEMO_TENANT_PROFESSIONAL,
|
||||
"user_id": uuid.UUID("50000000-0000-0000-0000-000000000015"), # Javier Navarro Prieto - Responsable de Compras
|
||||
"role": "procurement",
|
||||
"invited_by": OWNER_LA_ESPIGA,
|
||||
"is_owner": False
|
||||
},
|
||||
{
|
||||
"tenant_id": DEMO_TENANT_LA_ESPIGA,
|
||||
"tenant_id": DEMO_TENANT_PROFESSIONAL,
|
||||
"user_id": uuid.UUID("50000000-0000-0000-0000-000000000016"), # Laura Delgado Santos - Técnica de Mantenimiento
|
||||
"role": "maintenance",
|
||||
"invited_by": OWNER_LA_ESPIGA,
|
||||
@@ -198,7 +197,8 @@ async def seed_tenant_members(db: AsyncSession) -> dict:
|
||||
skipped_count = 0
|
||||
|
||||
# First, verify that template tenants exist
|
||||
for tenant_id in [DEMO_TENANT_SAN_PABLO, DEMO_TENANT_LA_ESPIGA]:
|
||||
for member_data in TENANT_MEMBERS_DATA:
|
||||
tenant_id = member_data["tenant_id"]
|
||||
result = await db.execute(
|
||||
select(Tenant).where(Tenant.id == tenant_id)
|
||||
)
|
||||
@@ -206,8 +206,8 @@ async def seed_tenant_members(db: AsyncSession) -> dict:
|
||||
|
||||
if not tenant:
|
||||
logger.error(
|
||||
f"Template tenant not found: {tenant_id}",
|
||||
tenant_id=str(tenant_id)
|
||||
"Template tenant not found: %s",
|
||||
str(tenant_id)
|
||||
)
|
||||
logger.error("Please run seed_demo_tenants.py first!")
|
||||
return {
|
||||
@@ -219,10 +219,12 @@ async def seed_tenant_members(db: AsyncSession) -> dict:
|
||||
}
|
||||
|
||||
logger.info(
|
||||
f"✓ Template tenant found: {tenant.name}",
|
||||
"✓ Template tenant found: %s",
|
||||
tenant.name,
|
||||
tenant_id=str(tenant_id),
|
||||
tenant_name=tenant.name
|
||||
)
|
||||
break # Only need to verify one tenant exists, then proceed with member creation
|
||||
|
||||
# Now seed the tenant members
|
||||
for member_data in TENANT_MEMBERS_DATA:
|
||||
|
||||
Reference in New Issue
Block a user