feat: complete CMS as fully autonomous self-contained module
Transform CMS from a thin wrapper into a fully self-contained module with all code living within app/modules/cms/: Module Structure: - models/: ContentPage model (canonical location with dynamic discovery) - schemas/: Pydantic schemas for API validation - services/: ContentPageService business logic - exceptions/: Module-specific exceptions - routes/api/: REST API endpoints (admin, vendor, shop) - routes/pages/: HTML page routes (admin, vendor) - templates/cms/: Jinja2 templates (namespaced) - static/: JavaScript files (admin/vendor) - locales/: i18n translations (en, fr, de, lb) Key Changes: - Move ContentPage model to module with dynamic model discovery - Create Pydantic schemas package for request/response validation - Extract API routes from app/api/v1/*/ to module - Extract page routes from admin_pages.py/vendor_pages.py to module - Move static JS files to module with dedicated mount point - Update templates to use cms_static for module assets - Add module static file mounting in main.py - Delete old scattered files (no shims - hard errors on old imports) This establishes the pattern for migrating other modules to be fully autonomous and independently deployable. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -37,7 +37,7 @@ from sqlalchemy import select
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.core.database import SessionLocal
|
||||
from models.database.content_page import ContentPage
|
||||
from app.modules.cms.models import ContentPage
|
||||
|
||||
# ============================================================================
|
||||
# DEFAULT PAGE CONTENT
|
||||
|
||||
@@ -17,7 +17,7 @@ from datetime import UTC, datetime
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.core.database import SessionLocal
|
||||
from models.database.content_page import ContentPage
|
||||
from app.modules.cms.models import ContentPage
|
||||
from models.database.vendor import Vendor
|
||||
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ project_root = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(project_root))
|
||||
|
||||
from app.core.database import SessionLocal
|
||||
from app.services.content_page_service import content_page_service
|
||||
from app.modules.cms.services import content_page_service
|
||||
|
||||
|
||||
def create_platform_pages():
|
||||
@@ -38,7 +38,7 @@ def create_platform_pages():
|
||||
print()
|
||||
|
||||
# Import ContentPage for checking existing pages
|
||||
from models.database.content_page import ContentPage
|
||||
from app.modules.cms.models import ContentPage
|
||||
|
||||
# ========================================================================
|
||||
# 1. PLATFORM HOMEPAGE
|
||||
|
||||
@@ -51,9 +51,9 @@ from app.core.config import settings
|
||||
from app.core.database import SessionLocal
|
||||
from app.core.environment import get_environment, is_production
|
||||
from middleware.auth import AuthManager
|
||||
from app.modules.cms.models import ContentPage
|
||||
from models.database.admin import PlatformAlert
|
||||
from models.database.company import Company
|
||||
from models.database.content_page import ContentPage
|
||||
from models.database.customer import Customer, CustomerAddress
|
||||
from models.database.marketplace_import_job import MarketplaceImportJob
|
||||
from models.database.marketplace_product import MarketplaceProduct
|
||||
|
||||
Reference in New Issue
Block a user