refactor: migrate templates and static files to self-contained modules
Templates Migration: - Migrate admin templates to modules (tenancy, billing, monitoring, marketplace, etc.) - Migrate vendor templates to modules (tenancy, billing, orders, messaging, etc.) - Migrate storefront templates to modules (catalog, customers, orders, cart, checkout, cms) - Migrate public templates to modules (billing, marketplace, cms) - Keep shared templates in app/templates/ (base.html, errors/, partials/, macros/) - Migrate letzshop partials to marketplace module Static Files Migration: - Migrate admin JS to modules: tenancy (23 files), core (5 files), monitoring (1 file) - Migrate vendor JS to modules: tenancy (4 files), core (2 files) - Migrate shared JS: vendor-selector.js to core, media-picker.js to cms - Migrate storefront JS: storefront-layout.js to core - Keep framework JS in static/ (api-client, utils, money, icons, log-config, lib/) - Update all template references to use module_static paths Naming Consistency: - Rename static/platform/ to static/public/ - Rename app/templates/platform/ to app/templates/public/ - Update all extends and static references Documentation: - Update module-system.md with shared templates documentation - Update frontend-structure.md with new module JS organization Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,13 +1,2 @@
|
||||
# app/modules/analytics/routes/pages/__init__.py
|
||||
"""
|
||||
Analytics module page routes.
|
||||
|
||||
Provides HTML page endpoints for analytics views:
|
||||
- Vendor pages: Analytics dashboard for vendors
|
||||
"""
|
||||
|
||||
from app.modules.analytics.routes.pages.vendor import router as vendor_router
|
||||
|
||||
# Note: Analytics has no admin pages - admin uses the main dashboard
|
||||
|
||||
__all__ = ["vendor_router"]
|
||||
"""Analytics module page routes."""
|
||||
|
||||
87
app/modules/analytics/routes/pages/admin.py
Normal file
87
app/modules/analytics/routes/pages/admin.py
Normal file
@@ -0,0 +1,87 @@
|
||||
# app/modules/analytics/routes/pages/admin.py
|
||||
"""
|
||||
Analytics Admin Page Routes (HTML rendering).
|
||||
|
||||
Admin pages for code quality and analytics:
|
||||
- Code quality dashboard
|
||||
- Violations list
|
||||
- Violation detail
|
||||
"""
|
||||
|
||||
from fastapi import APIRouter, Depends, Path, Request
|
||||
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.templates_config import templates
|
||||
from models.database.admin_menu_config import FrontendType
|
||||
from models.database.user import User
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# CODE QUALITY & ARCHITECTURE ROUTES
|
||||
# ============================================================================
|
||||
|
||||
|
||||
@router.get("/code-quality", response_class=HTMLResponse, include_in_schema=False)
|
||||
async def admin_code_quality_dashboard(
|
||||
request: Request,
|
||||
current_user: User = Depends(
|
||||
require_menu_access("code-quality", FrontendType.ADMIN)
|
||||
),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
Render code quality dashboard.
|
||||
Shows architecture violations, trends, and technical debt score.
|
||||
"""
|
||||
return templates.TemplateResponse(
|
||||
"dev_tools/admin/code-quality-dashboard.html",
|
||||
get_admin_context(request, current_user),
|
||||
)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/code-quality/violations", response_class=HTMLResponse, include_in_schema=False
|
||||
)
|
||||
async def admin_code_quality_violations(
|
||||
request: Request,
|
||||
current_user: User = Depends(
|
||||
require_menu_access("code-quality", FrontendType.ADMIN)
|
||||
),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
Render violations list page.
|
||||
Shows all violations with filtering and sorting options.
|
||||
"""
|
||||
return templates.TemplateResponse(
|
||||
"dev_tools/admin/code-quality-violations.html",
|
||||
get_admin_context(request, current_user),
|
||||
)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/code-quality/violations/{violation_id}",
|
||||
response_class=HTMLResponse,
|
||||
include_in_schema=False,
|
||||
)
|
||||
async def admin_code_quality_violation_detail(
|
||||
request: Request,
|
||||
violation_id: int = Path(..., description="Violation ID"),
|
||||
current_user: User = Depends(
|
||||
require_menu_access("code-quality", FrontendType.ADMIN)
|
||||
),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""
|
||||
Render violation detail page.
|
||||
Shows violation details, code context, assignments, and comments.
|
||||
"""
|
||||
return templates.TemplateResponse(
|
||||
"dev_tools/admin/code-quality-violation-detail.html",
|
||||
get_admin_context(request, current_user, violation_id=violation_id),
|
||||
)
|
||||
@@ -12,7 +12,7 @@ from fastapi.responses import HTMLResponse
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.api.deps import get_current_vendor_from_cookie_or_header, get_db
|
||||
from app.services.platform_settings_service import platform_settings_service # noqa: MOD-004 - shared platform service
|
||||
from app.modules.core.services.platform_settings_service import platform_settings_service # noqa: MOD-004 - shared platform service
|
||||
from app.templates_config import templates
|
||||
from models.database.user import User
|
||||
from models.database.vendor import Vendor
|
||||
|
||||
@@ -18,7 +18,7 @@ from typing import Any
|
||||
from sqlalchemy import func
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.exceptions import AdminOperationException, VendorNotFoundException
|
||||
from app.modules.tenancy.exceptions import AdminOperationException, VendorNotFoundException
|
||||
from app.modules.customers.models.customer import Customer
|
||||
from app.modules.inventory.models import Inventory
|
||||
from app.modules.marketplace.models import MarketplaceImportJob, MarketplaceProduct
|
||||
|
||||
@@ -93,7 +93,7 @@ class UsageService:
|
||||
|
||||
Returns current usage, limits, and upgrade recommendations.
|
||||
"""
|
||||
from app.services.subscription_service import subscription_service
|
||||
from app.modules.billing.services.subscription_service import subscription_service
|
||||
|
||||
# Get subscription
|
||||
subscription = subscription_service.get_or_create_subscription(db, vendor_id)
|
||||
@@ -151,7 +151,7 @@ class UsageService:
|
||||
Returns:
|
||||
LimitCheckData with proceed status and upgrade info
|
||||
"""
|
||||
from app.services.subscription_service import subscription_service
|
||||
from app.modules.billing.services.subscription_service import subscription_service
|
||||
|
||||
if limit_type == "orders":
|
||||
can_proceed, message = subscription_service.can_create_order(db, vendor_id)
|
||||
|
||||
Reference in New Issue
Block a user