refactor(cms): migrate store theme UI from tenancy to CMS module

Move store theme admin pages, templates, and JS from tenancy module
to CMS module where the data layer (model, service, API, schemas)
already lives. Eliminates split ownership.

Moved:
- Route handlers: GET /store-themes, GET /stores/{code}/theme
- Templates: store-theme.html, store-themes.html
- JS: store-theme.js, store-themes.js
- Updated static references: tenancy_static → cms_static

Deleted old tenancy files (no remaining references).
Menu item in CMS definition already pointed to correct route.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-18 10:30:09 +02:00
parent 21e4ac5124
commit 51a2114e02
7 changed files with 52 additions and 50 deletions

View File

@@ -2,7 +2,8 @@
"""
CMS Admin Page Routes (HTML rendering).
Admin pages for managing platform and store content pages.
Admin pages for managing platform and store content pages,
and store theme customization.
"""
from fastapi import APIRouter, Depends, Path, Request
@@ -10,6 +11,7 @@ from fastapi.responses import HTMLResponse
from sqlalchemy.orm import Session
from app.api.deps import get_db, require_menu_access
from app.modules.core.utils.page_context import get_admin_context
from app.modules.enums import FrontendType
from app.modules.tenancy.models import User
from app.templates_config import templates
@@ -86,3 +88,49 @@ async def admin_content_page_edit(
"page_id": page_id,
},
)
# ============================================================================
# STORE THEMES
# ============================================================================
@router.get("/store-themes", response_class=HTMLResponse, include_in_schema=False)
async def admin_store_themes_page(
request: Request,
current_user: User = Depends(
require_menu_access("store-themes", FrontendType.ADMIN)
),
db: Session = Depends(get_db),
):
"""
Render store themes selection page.
Allows admins to select a store to customize their theme.
"""
return templates.TemplateResponse(
"cms/admin/store-themes.html",
get_admin_context(request, db, current_user),
)
@router.get(
"/stores/{store_code}/theme",
response_class=HTMLResponse,
include_in_schema=False,
)
async def admin_store_theme_page(
request: Request,
store_code: str = Path(..., description="Store code"),
current_user: User = Depends(
require_menu_access("store-themes", FrontendType.ADMIN)
),
db: Session = Depends(get_db),
):
"""
Render store theme customization page.
Allows admins to customize colors, fonts, layout, and branding.
"""
return templates.TemplateResponse(
"cms/admin/store-theme.html",
get_admin_context(request, db, current_user, store_code=store_code),
)

View File

@@ -459,5 +459,5 @@
{% endblock %}
{% block extra_scripts %}
<script defer src="{{ url_for('tenancy_static', path='admin/js/store-theme.js') }}"></script>
<script defer src="{{ url_for('cms_static', path='admin/js/store-theme.js') }}"></script>
{% endblock %}

View File

@@ -125,5 +125,5 @@
{% block extra_scripts %}
<script defer src="https://cdn.jsdelivr.net/npm/tom-select@2.3.1/dist/js/tom-select.complete.min.js"></script>
<script defer src="{{ url_for('tenancy_static', path='admin/js/store-themes.js') }}"></script>
<script defer src="{{ url_for('cms_static', path='admin/js/store-themes.js') }}"></script>
{% endblock %}

View File

@@ -243,52 +243,6 @@ async def admin_store_roles_page(
)
# ============================================================================
# STORE THEMES ROUTES
# ============================================================================
@router.get("/store-themes", response_class=HTMLResponse, include_in_schema=False)
async def admin_store_themes_page(
request: Request,
current_user: User = Depends(
require_menu_access("store-themes", FrontendType.ADMIN)
),
db: Session = Depends(get_db),
):
"""
Render store themes selection page.
Allows admins to select a store to customize their theme.
"""
return templates.TemplateResponse(
"tenancy/admin/store-themes.html",
get_admin_context(request, db, current_user),
)
@router.get(
"/stores/{store_code}/theme",
response_class=HTMLResponse,
include_in_schema=False,
)
async def admin_store_theme_page(
request: Request,
store_code: str = Path(..., description="Store code"),
current_user: User = Depends(
require_menu_access("store-themes", FrontendType.ADMIN)
),
db: Session = Depends(get_db),
):
"""
Render store theme customization page.
Allows admins to customize colors, fonts, layout, and branding.
"""
return templates.TemplateResponse(
"tenancy/admin/store-theme.html",
get_admin_context(request, db, current_user, store_code=store_code),
)
# ============================================================================
# MERCHANT USER MANAGEMENT ROUTES (All Admins)
# ============================================================================

View File

@@ -242,7 +242,7 @@ This proposal covers the CMS foundation. The broader [storefront builder vision]
| Section partials | `app/modules/cms/templates/cms/platform/sections/_*.html` |
| CMS definition (admin menu) | `app/modules/cms/definition.py` |
| Tenancy definition (admin menu) | `app/modules/tenancy/definition.py` |
| Store theme page | `app/modules/tenancy/templates/tenancy/admin/store-theme.html` |
| Store theme page | `app/modules/cms/templates/cms/admin/store-theme.html` |
| Store themes list | `app/modules/cms/templates/cms/admin/store-themes.html` |
| Storefront landing templates | `app/modules/cms/templates/cms/storefront/landing-*.html` |
| Seed data | `scripts/seed/create_default_content_pages.py` |