From 7e39bb056445f13020e7ad980936c3a39875db9f Mon Sep 17 00:00:00 2001 From: Samir Boulahtit Date: Fri, 23 Jan 2026 20:03:13 +0100 Subject: [PATCH] fix: resolve homepage sections editor and rendering issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix sections editor not showing by converting isHomepage getter to property - Add Alpine Collapse plugin for accordion animations - Fix Quill editor content not syncing after page load - Add platform dropdown to content page edit form - Create shared templates config (app/templates_config.py) with i18n globals to make _() translation function available in Jinja2 macros - Fix pricing template field names (monthly_price → price_monthly) - Fix translation key (pricing.save_20 → pricing.save_months) - Add tiers context to CMS homepage route for pricing section - Fix architecture validation issues (language defaults, inline SVGs → $icon) Co-Authored-By: Claude Opus 4.5 --- app/routes/platform_pages.py | 25 ++++++- app/templates/admin/base.html | 5 +- app/templates/admin/content-page-edit.html | 45 ++++++++----- app/templates/platform/homepage-default.html | 2 +- app/templates/platform/sections/_hero.html | 4 +- app/templates/platform/sections/_pricing.html | 6 +- app/templates/shared/macros/richtext.html | 3 + app/templates_config.py | 34 ++++++++++ main.py | 4 +- static/admin/js/content-page-edit.js | 67 +++++++++++++++++-- 10 files changed, 161 insertions(+), 34 deletions(-) create mode 100644 app/templates_config.py diff --git a/app/routes/platform_pages.py b/app/routes/platform_pages.py index 1fc045f8..540b03b0 100644 --- a/app/routes/platform_pages.py +++ b/app/routes/platform_pages.py @@ -11,7 +11,7 @@ from pathlib import Path from fastapi import APIRouter, Depends, HTTPException, Request from fastapi.responses import HTMLResponse -from fastapi.templating import Jinja2Templates +from app.templates_config import templates from sqlalchemy.orm import Session from app.core.config import settings @@ -24,8 +24,8 @@ logger = logging.getLogger(__name__) # Get the templates directory BASE_DIR = Path(__file__).resolve().parent.parent.parent -TEMPLATES_DIR = BASE_DIR / "app" / "templates" -templates = Jinja2Templates(directory=str(TEMPLATES_DIR)) +# TEMPLATES_DIR moved to app.templates_config +# templates imported from app.templates_config def get_platform_context(request: Request, db: Session) -> dict: @@ -171,6 +171,25 @@ async def homepage( context["page"] = cms_homepage context["platform"] = platform + # Include subscription tiers for pricing section + from models.database.subscription import TIER_LIMITS, TierCode + + tiers = [] + for tier_code, limits in TIER_LIMITS.items(): + tiers.append({ + "code": tier_code.value, + "name": limits["name"], + "price_monthly": limits["price_monthly_cents"] / 100, + "price_annual": (limits["price_annual_cents"] / 100) if limits.get("price_annual_cents") else None, + "orders_per_month": limits.get("orders_per_month"), + "products_limit": limits.get("products_limit"), + "team_members": limits.get("team_members"), + "features": limits.get("features", []), + "is_popular": tier_code == TierCode.PROFESSIONAL, + "is_enterprise": tier_code == TierCode.ENTERPRISE, + }) + context["tiers"] = tiers + template_name = cms_homepage.template or "default" template_path = f"platform/homepage-{template_name}.html" diff --git a/app/templates/admin/base.html b/app/templates/admin/base.html index 02e1374f..d7e4bba8 100644 --- a/app/templates/admin/base.html +++ b/app/templates/admin/base.html @@ -130,7 +130,10 @@ - + + + +