feat: implement /platforms/ URL prefix routing strategy
- Update middleware to use /platforms/{code}/ prefix for dev routing
- Change DEFAULT_PLATFORM_CODE from 'oms' to 'main'
- Add 'main' platform for main marketing site (wizamart.lu)
- Remove hardcoded /oms and /loyalty routes from main.py
- Update platform_pages.py homepage to handle vendor landing pages
URL structure:
- localhost:9999/ → Main marketing site ('main' platform)
- localhost:9999/platforms/oms/ → OMS platform
- localhost:9999/platforms/loyalty/ → Loyalty platform
- oms.lu/ → OMS platform (production)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -90,16 +90,102 @@ async def homepage(
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
Platform marketing homepage.
|
||||
Homepage handler.
|
||||
|
||||
Displays:
|
||||
- Hero section with value proposition
|
||||
- Pricing tier cards
|
||||
- Add-ons section
|
||||
- Letzshop vendor finder
|
||||
- Call to action for signup
|
||||
Handles two scenarios:
|
||||
1. Vendor on custom domain (vendor.com) → Show vendor landing page or redirect to shop
|
||||
2. Platform marketing site → Show platform homepage from CMS or default template
|
||||
|
||||
URL routing:
|
||||
- localhost:9999/ → Main marketing site ('main' platform)
|
||||
- localhost:9999/platforms/oms/ → OMS platform (middleware rewrites to /)
|
||||
- oms.lu/ → OMS platform (domain-based)
|
||||
- shop.mycompany.com/ → Vendor landing page (custom domain)
|
||||
"""
|
||||
from fastapi.responses import RedirectResponse
|
||||
|
||||
# Get platform and vendor from middleware
|
||||
platform = getattr(request.state, "platform", None)
|
||||
vendor = getattr(request.state, "vendor", None)
|
||||
|
||||
# Scenario 1: Vendor detected (custom domain like vendor.com)
|
||||
if vendor:
|
||||
logger.debug(f"[HOMEPAGE] Vendor detected: {vendor.subdomain}")
|
||||
|
||||
# Get platform_id (use platform from context or default to 1 for OMS)
|
||||
platform_id = platform.id if platform else 1
|
||||
|
||||
# Try to find vendor landing page (slug='landing' or 'home')
|
||||
landing_page = content_page_service.get_page_for_vendor(
|
||||
db, platform_id=platform_id, slug="landing", vendor_id=vendor.id, include_unpublished=False
|
||||
)
|
||||
|
||||
if not landing_page:
|
||||
landing_page = content_page_service.get_page_for_vendor(
|
||||
db, platform_id=platform_id, slug="home", vendor_id=vendor.id, include_unpublished=False
|
||||
)
|
||||
|
||||
if landing_page:
|
||||
# Render landing page with selected template
|
||||
from app.routes.shop_pages import get_shop_context
|
||||
|
||||
template_name = landing_page.template or "default"
|
||||
template_path = f"vendor/landing-{template_name}.html"
|
||||
|
||||
logger.info(f"[HOMEPAGE] Rendering vendor landing page: {template_path}")
|
||||
return templates.TemplateResponse(
|
||||
template_path, get_shop_context(request, db=db, page=landing_page)
|
||||
)
|
||||
|
||||
# No landing page - redirect to shop
|
||||
vendor_context = getattr(request.state, "vendor_context", None)
|
||||
access_method = (
|
||||
vendor_context.get("detection_method", "unknown")
|
||||
if vendor_context
|
||||
else "unknown"
|
||||
)
|
||||
|
||||
if access_method == "path":
|
||||
full_prefix = (
|
||||
vendor_context.get("full_prefix", "/vendor/")
|
||||
if vendor_context
|
||||
else "/vendor/"
|
||||
)
|
||||
return RedirectResponse(
|
||||
url=f"{full_prefix}{vendor.subdomain}/shop/", status_code=302
|
||||
)
|
||||
# Domain/subdomain - redirect to /shop/
|
||||
return RedirectResponse(url="/shop/", status_code=302)
|
||||
|
||||
# Scenario 2: Platform marketing site (no vendor)
|
||||
# Try to load platform homepage from CMS
|
||||
platform_id = platform.id if platform else 1
|
||||
|
||||
cms_homepage = content_page_service.get_platform_page(
|
||||
db, platform_id=platform_id, slug="home", include_unpublished=False
|
||||
)
|
||||
|
||||
if not cms_homepage:
|
||||
cms_homepage = content_page_service.get_platform_page(
|
||||
db, platform_id=platform_id, slug="platform_homepage", include_unpublished=False
|
||||
)
|
||||
|
||||
if cms_homepage:
|
||||
# Use CMS-based homepage with template selection
|
||||
context = get_platform_context(request, db)
|
||||
context["page"] = cms_homepage
|
||||
context["platform"] = platform
|
||||
|
||||
template_name = cms_homepage.template or "default"
|
||||
template_path = f"platform/homepage-{template_name}.html"
|
||||
|
||||
logger.info(f"[HOMEPAGE] Rendering CMS homepage with template: {template_path}")
|
||||
return templates.TemplateResponse(template_path, context)
|
||||
|
||||
# Fallback: Default wizamart homepage (no CMS content)
|
||||
logger.info("[HOMEPAGE] No CMS homepage found, using default wizamart template")
|
||||
context = get_platform_context(request, db)
|
||||
context["platform"] = platform
|
||||
|
||||
# Fetch tiers for display (use API service internally)
|
||||
from models.database.subscription import TIER_LIMITS, TierCode
|
||||
|
||||
Reference in New Issue
Block a user