feat: trim platform modules, rename platforms, fix seed output
- Rename platforms: Orion OMS → OMS, Orion → Wizard, Loyalty+ → Loyalty - Per-platform module assignment: core modules always enabled, optional modules selectively enabled per platform instead of enabling all 18 - Rename demo store Orion → WizaTech to avoid confusion with app name - Fix false "already exist" warnings for customers/products in seed (broken post-flush id detection replaced with simple counter) - Make dev port use API_PORT from .env instead of hardcoded 9999 - Add platforms section with dev URLs to init-prod summary - Add merchant panel and customer login URLs to seed next steps - Merge alembic heads (z_store_domain_platform_id + tenancy_001) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -176,7 +176,7 @@ def create_default_platforms(db: Session) -> list[Platform]:
|
||||
platform_defs = [
|
||||
{
|
||||
"code": "oms",
|
||||
"name": "Orion OMS",
|
||||
"name": "OMS",
|
||||
"description": "Order Management System for multi-store e-commerce",
|
||||
"domain": "omsflow.lu",
|
||||
"path_prefix": "oms",
|
||||
@@ -187,7 +187,7 @@ def create_default_platforms(db: Session) -> list[Platform]:
|
||||
},
|
||||
{
|
||||
"code": "main",
|
||||
"name": "Orion",
|
||||
"name": "Wizard",
|
||||
"description": "Main marketing site showcasing all Orion platforms",
|
||||
"domain": "wizard.lu",
|
||||
"path_prefix": None,
|
||||
@@ -198,7 +198,7 @@ def create_default_platforms(db: Session) -> list[Platform]:
|
||||
},
|
||||
{
|
||||
"code": "loyalty",
|
||||
"name": "Loyalty+",
|
||||
"name": "Loyalty",
|
||||
"description": "Customer loyalty program platform for Luxembourg businesses",
|
||||
"domain": "rewardflow.lu",
|
||||
"path_prefix": "loyalty",
|
||||
@@ -488,17 +488,26 @@ def create_subscription_tiers(db: Session, platform: Platform) -> int:
|
||||
def create_platform_modules(db: Session, platforms: list[Platform]) -> int:
|
||||
"""Create PlatformModule records for all platforms.
|
||||
|
||||
Enables all discovered modules for each platform so the app works
|
||||
out of the box. Admins can disable optional modules later via the API.
|
||||
Core modules are enabled for every platform. Optional modules are
|
||||
selectively enabled per platform. All other modules are created but
|
||||
disabled (available to toggle on later via the admin API).
|
||||
"""
|
||||
from app.modules.registry import MODULES
|
||||
from app.modules.registry import MODULES, is_core_module
|
||||
|
||||
# Optional modules enabled per platform (core modules always enabled)
|
||||
PLATFORM_MODULES = {
|
||||
"oms": ["inventory", "catalog", "orders", "marketplace", "analytics", "cart", "checkout"],
|
||||
"main": ["analytics", "monitoring", "dev-tools"],
|
||||
"loyalty": ["loyalty"],
|
||||
}
|
||||
|
||||
now = datetime.now(UTC)
|
||||
records_created = 0
|
||||
|
||||
for platform in platforms:
|
||||
enabled_extras = set(PLATFORM_MODULES.get(platform.code, []))
|
||||
|
||||
for code in MODULES:
|
||||
# Check if record already exists
|
||||
existing = db.execute(
|
||||
select(PlatformModule).where(
|
||||
PlatformModule.platform_id == platform.id,
|
||||
@@ -509,11 +518,12 @@ def create_platform_modules(db: Session, platforms: list[Platform]) -> int:
|
||||
if existing:
|
||||
continue
|
||||
|
||||
enabled = is_core_module(code) or code in enabled_extras
|
||||
pm = PlatformModule(
|
||||
platform_id=platform.id,
|
||||
module_code=code,
|
||||
is_enabled=True,
|
||||
enabled_at=now,
|
||||
is_enabled=enabled,
|
||||
enabled_at=now if enabled else None,
|
||||
config={},
|
||||
)
|
||||
db.add(pm) # noqa: PERF006
|
||||
@@ -649,16 +659,38 @@ def print_summary(db: Session):
|
||||
print(f" Admin settings: {setting_count}")
|
||||
print(f" Sub. tiers: {tier_count}")
|
||||
|
||||
# Show platforms
|
||||
platforms = db.query(Platform).order_by(Platform.code).all()
|
||||
enabled_counts = {}
|
||||
for pm in db.query(PlatformModule).filter(PlatformModule.is_enabled.is_(True)).all():
|
||||
enabled_counts[pm.platform_id] = enabled_counts.get(pm.platform_id, 0) + 1
|
||||
|
||||
port = settings.api_port
|
||||
print("\n" + "─" * 70)
|
||||
print("🌐 PLATFORMS")
|
||||
print("─" * 70)
|
||||
for p in platforms:
|
||||
n_enabled = enabled_counts.get(p.id, 0)
|
||||
if p.code == "main":
|
||||
dev_url = f"http://localhost:{port}/"
|
||||
else:
|
||||
dev_url = f"http://localhost:{port}/platforms/{p.code}/"
|
||||
print(f" {p.name} ({p.code})")
|
||||
print(f" Domain: {p.domain}")
|
||||
print(f" Dev URL: {dev_url}")
|
||||
print(f" Modules: {n_enabled} enabled")
|
||||
|
||||
print("\n" + "─" * 70)
|
||||
print("🔐 ADMIN CREDENTIALS")
|
||||
print("─" * 70)
|
||||
admin_url = f"http://localhost:{port}/admin/login"
|
||||
print(" Super Admin (all platforms):")
|
||||
print(" URL: /admin/login")
|
||||
print(f" URL: {admin_url}")
|
||||
print(f" Username: {settings.admin_username}")
|
||||
print(f" Password: {settings.admin_password}") # noqa: SEC021
|
||||
print()
|
||||
print(" Loyalty Platform Admin (loyalty only):")
|
||||
print(" URL: /admin/login")
|
||||
print(f" URL: {admin_url}")
|
||||
print(" Username: loyalty_admin")
|
||||
print(" Password: admin123")
|
||||
print("─" * 70)
|
||||
@@ -677,17 +709,16 @@ def print_summary(db: Session):
|
||||
print(" Change them in production via .env file")
|
||||
|
||||
print("\n🚀 NEXT STEPS:")
|
||||
print(" 1. Login to admin panel")
|
||||
if is_production():
|
||||
print(f" 1. Login to admin panel: {admin_url}")
|
||||
print(" 2. CHANGE DEFAULT PASSWORD IMMEDIATELY!") # noqa: SEC021
|
||||
print(" 3. Configure admin settings")
|
||||
print(" 4. Create first store")
|
||||
else:
|
||||
print(" 2. Create demo data: make seed-demo")
|
||||
print(" 3. Start development: make dev")
|
||||
|
||||
print("\n📝 FOR DEMO DATA (Development only):")
|
||||
print(" make seed-demo")
|
||||
print(" 1. Start development: make dev")
|
||||
print(f" 2. Admin panel: {admin_url}")
|
||||
print(f" 3. Merchant panel: http://localhost:{port}/merchants/login")
|
||||
print(" 4. Create demo data: make seed-demo")
|
||||
|
||||
|
||||
# =============================================================================
|
||||
|
||||
Reference in New Issue
Block a user