Improve the frontend 2
This commit is contained in:
@@ -55,7 +55,6 @@ TENANTS_DATA = [
|
||||
"id": DEMO_TENANT_SAN_PABLO,
|
||||
"name": "Panadería San Pablo",
|
||||
"business_model": "san_pablo",
|
||||
"subscription_tier": "demo_template",
|
||||
"is_demo": False, # Template tenants are not marked as demo
|
||||
"is_demo_template": True, # They are templates for cloning
|
||||
"is_active": True,
|
||||
@@ -88,7 +87,6 @@ TENANTS_DATA = [
|
||||
"id": DEMO_TENANT_LA_ESPIGA,
|
||||
"name": "Panadería La Espiga - Obrador Central",
|
||||
"business_model": "la_espiga",
|
||||
"subscription_tier": "demo_template",
|
||||
"is_demo": False,
|
||||
"is_demo_template": True,
|
||||
"is_active": True,
|
||||
@@ -173,6 +171,41 @@ async def seed_tenants(db: AsyncSession) -> dict:
|
||||
db.add(tenant)
|
||||
created_count += 1
|
||||
|
||||
# Flush to get tenant IDs before creating subscriptions
|
||||
await db.flush()
|
||||
|
||||
# Create demo subscriptions for all tenants (enterprise tier for full demo access)
|
||||
from app.models.tenants import Subscription
|
||||
|
||||
for tenant_data in TENANTS_DATA:
|
||||
tenant_id = tenant_data["id"]
|
||||
|
||||
# Check if subscription already exists
|
||||
result = await db.execute(
|
||||
select(Subscription).where(Subscription.tenant_id == tenant_id)
|
||||
)
|
||||
existing_subscription = result.scalars().first()
|
||||
|
||||
if not existing_subscription:
|
||||
logger.info(
|
||||
"Creating demo subscription for tenant",
|
||||
tenant_id=str(tenant_id),
|
||||
plan="enterprise"
|
||||
)
|
||||
|
||||
subscription = Subscription(
|
||||
tenant_id=tenant_id,
|
||||
plan="enterprise", # Demo templates get full access
|
||||
status="active",
|
||||
monthly_price=0.0, # Free for demo
|
||||
billing_cycle="monthly",
|
||||
max_users=-1, # Unlimited
|
||||
max_locations=-1,
|
||||
max_products=-1,
|
||||
features={}
|
||||
)
|
||||
db.add(subscription)
|
||||
|
||||
# Commit all changes
|
||||
await db.commit()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user