diff --git a/Makefile b/Makefile index 02b53904..087b6b13 100644 --- a/Makefile +++ b/Makefile @@ -44,7 +44,7 @@ setup: install-all migrate-up init-prod # ============================================================================= dev: - $(PYTHON) -m uvicorn main:app --reload --host 0.0.0.0 --port 9999 + $(PYTHON) -m uvicorn main:app --reload --host 0.0.0.0 --port $(or $(API_PORT),8000) # ============================================================================= # DATABASE MIGRATIONS diff --git a/alembic/versions/a44f4956cfb1_merge_heads.py b/alembic/versions/a44f4956cfb1_merge_heads.py new file mode 100644 index 00000000..39094c60 --- /dev/null +++ b/alembic/versions/a44f4956cfb1_merge_heads.py @@ -0,0 +1,26 @@ +"""merge heads + +Revision ID: a44f4956cfb1 +Revises: z_store_domain_platform_id, tenancy_001 +Create Date: 2026-02-17 16:10:36.287976 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision: str = 'a44f4956cfb1' +down_revision: Union[str, None] = ('z_store_domain_platform_id', 'tenancy_001') +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + pass + + +def downgrade() -> None: + pass diff --git a/scripts/seed/init_production.py b/scripts/seed/init_production.py index 6bba8f92..3b372435 100644 --- a/scripts/seed/init_production.py +++ b/scripts/seed/init_production.py @@ -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") # ============================================================================= diff --git a/scripts/seed/seed_demo.py b/scripts/seed/seed_demo.py index 6f19f9ae..ceef9c67 100644 --- a/scripts/seed/seed_demo.py +++ b/scripts/seed/seed_demo.py @@ -144,12 +144,12 @@ DEMO_COMPANIES = [ DEMO_STORES = [ { "merchant_index": 0, # WizaCorp - "store_code": "ORION", - "name": "Orion", - "subdomain": "orion", + "store_code": "WIZATECH", + "name": "WizaTech", + "subdomain": "wizatech", "description": "Premium electronics and gadgets marketplace", "theme_preset": "modern", - "custom_domain": "orion.shop", + "custom_domain": "wizatech.shop", }, { "merchant_index": 0, # WizaCorp @@ -216,7 +216,7 @@ DEMO_TEAM_MEMBERS = [ "password": "password123", # noqa: SEC001 "first_name": "Alice", "last_name": "Manager", - "store_codes": ["ORION", "WIZAGADGETS"], # manages two stores + "store_codes": ["WIZATECH", "WIZAGADGETS"], # manages two stores "user_type": "member", }, { @@ -287,20 +287,20 @@ THEME_PRESETS = { # Store content page overrides (demonstrates CMS store override feature) # Each store can override platform default pages with custom content STORE_CONTENT_PAGES = { - "ORION": [ + "WIZATECH": [ { "slug": "about", - "title": "About Orion", + "title": "About WizaTech", "content": """
Your premier destination for cutting-edge electronics and innovative gadgets.
Founded by tech enthusiasts, Orion has been bringing the latest technology to customers since 2020. +
Founded by tech enthusiasts, WizaTech has been bringing the latest technology to customers since 2020. We carefully curate our selection to ensure you get only the best products at competitive prices.
-123 Tech Street, Luxembourg City
Open Monday-Saturday, 9am-7pm
Need help with your gadgets? Our tech experts are here to help!
123 Tech Street
Luxembourg City, L-1234
Luxembourg