feat: complete marketplace module self-containment
Migrate marketplace module to self-contained structure: - routes/api/admin.py - Admin API endpoints - routes/api/vendor.py - Vendor API endpoints - routes/pages/ - Page routes (placeholder) - models/letzshop.py - Letzshop model - models/marketplace_import_job.py - Import job model - models/marketplace_product.py - Product model - models/marketplace_product_translation.py - Translation model - schemas/marketplace_import_job.py - Import job schemas - schemas/marketplace_product.py - Product schemas - locales/ - Translations (en, de, fr, lu) Removed legacy route files replaced by api/ structure. Updated __init__.py files to use new structure. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,33 +2,36 @@
|
||||
"""
|
||||
Marketplace module route registration.
|
||||
|
||||
This module provides functions to register marketplace routes
|
||||
with module-based access control.
|
||||
This module provides marketplace routes with module-based access control.
|
||||
|
||||
NOTE: Routers are NOT auto-imported to avoid circular dependencies.
|
||||
Import directly from admin.py or vendor.py as needed:
|
||||
from app.modules.marketplace.routes.admin import admin_router, admin_letzshop_router
|
||||
from app.modules.marketplace.routes.vendor import vendor_router, vendor_letzshop_router
|
||||
Structure:
|
||||
- routes/api/ - REST API endpoints
|
||||
- routes/pages/ - HTML page rendering (templates)
|
||||
|
||||
NOTE: Routers are not eagerly imported here to avoid circular imports.
|
||||
Import directly from routes/api/admin.py or routes/api/vendor.py instead.
|
||||
"""
|
||||
|
||||
# Routers are imported on-demand to avoid circular dependencies
|
||||
# Do NOT add auto-imports here
|
||||
|
||||
__all__ = ["admin_router", "admin_letzshop_router", "vendor_router", "vendor_letzshop_router"]
|
||||
|
||||
|
||||
def __getattr__(name: str):
|
||||
"""Lazy import routers to avoid circular dependencies."""
|
||||
"""Lazy import of routers to avoid circular imports."""
|
||||
if name == "admin_router":
|
||||
from app.modules.marketplace.routes.admin import admin_router
|
||||
from app.modules.marketplace.routes.api.admin import admin_router
|
||||
|
||||
return admin_router
|
||||
elif name == "admin_letzshop_router":
|
||||
from app.modules.marketplace.routes.admin import admin_letzshop_router
|
||||
from app.modules.marketplace.routes.api.admin import admin_letzshop_router
|
||||
|
||||
return admin_letzshop_router
|
||||
elif name == "vendor_router":
|
||||
from app.modules.marketplace.routes.vendor import vendor_router
|
||||
from app.modules.marketplace.routes.api.vendor import vendor_router
|
||||
|
||||
return vendor_router
|
||||
elif name == "vendor_letzshop_router":
|
||||
from app.modules.marketplace.routes.vendor import vendor_letzshop_router
|
||||
from app.modules.marketplace.routes.api.vendor import vendor_letzshop_router
|
||||
|
||||
return vendor_letzshop_router
|
||||
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
||||
|
||||
|
||||
__all__ = ["admin_router", "admin_letzshop_router", "vendor_router", "vendor_letzshop_router"]
|
||||
|
||||
35
app/modules/marketplace/routes/api/__init__.py
Normal file
35
app/modules/marketplace/routes/api/__init__.py
Normal file
@@ -0,0 +1,35 @@
|
||||
# app/modules/marketplace/routes/api/__init__.py
|
||||
"""
|
||||
Marketplace module API routes.
|
||||
|
||||
Provides REST API endpoints for marketplace integration:
|
||||
- Admin API: Import jobs, vendor directory, marketplace products
|
||||
- Vendor API: Letzshop sync, product imports, exports
|
||||
|
||||
NOTE: Routers are not eagerly imported here to avoid circular imports.
|
||||
Import directly from admin.py or vendor.py instead.
|
||||
"""
|
||||
|
||||
|
||||
def __getattr__(name: str):
|
||||
"""Lazy import of routers to avoid circular imports."""
|
||||
if name == "admin_router":
|
||||
from app.modules.marketplace.routes.api.admin import admin_router
|
||||
|
||||
return admin_router
|
||||
elif name == "admin_letzshop_router":
|
||||
from app.modules.marketplace.routes.api.admin import admin_letzshop_router
|
||||
|
||||
return admin_letzshop_router
|
||||
elif name == "vendor_router":
|
||||
from app.modules.marketplace.routes.api.vendor import vendor_router
|
||||
|
||||
return vendor_router
|
||||
elif name == "vendor_letzshop_router":
|
||||
from app.modules.marketplace.routes.api.vendor import vendor_letzshop_router
|
||||
|
||||
return vendor_letzshop_router
|
||||
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
||||
|
||||
|
||||
__all__ = ["admin_router", "admin_letzshop_router", "vendor_router", "vendor_letzshop_router"]
|
||||
@@ -1,4 +1,4 @@
|
||||
# app/modules/marketplace/routes/admin.py
|
||||
# app/modules/marketplace/routes/api/admin.py
|
||||
"""
|
||||
Marketplace module admin routes.
|
||||
|
||||
@@ -11,13 +11,18 @@ Includes:
|
||||
- /letzshop/* - Letzshop integration
|
||||
"""
|
||||
|
||||
import importlib
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
from app.api.deps import require_module_access
|
||||
|
||||
# Import original routers (direct import to avoid circular dependency)
|
||||
from app.api.v1.admin.marketplace import router as marketplace_original_router
|
||||
from app.api.v1.admin.letzshop import router as letzshop_original_router
|
||||
# Import original routers using importlib to avoid circular imports
|
||||
# (direct import triggers app.api.v1.admin.__init__.py which imports us)
|
||||
_marketplace_module = importlib.import_module("app.api.v1.admin.marketplace")
|
||||
_letzshop_module = importlib.import_module("app.api.v1.admin.letzshop")
|
||||
marketplace_original_router = _marketplace_module.router
|
||||
letzshop_original_router = _letzshop_module.router
|
||||
|
||||
# Create module-aware router for marketplace
|
||||
admin_router = APIRouter(
|
||||
@@ -1,4 +1,4 @@
|
||||
# app/modules/marketplace/routes/vendor.py
|
||||
# app/modules/marketplace/routes/api/vendor.py
|
||||
"""
|
||||
Marketplace module vendor routes.
|
||||
|
||||
@@ -11,13 +11,18 @@ Includes:
|
||||
- /letzshop/* - Letzshop integration
|
||||
"""
|
||||
|
||||
import importlib
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
from app.api.deps import require_module_access
|
||||
|
||||
# Import original routers (direct import to avoid circular dependency)
|
||||
from app.api.v1.vendor.marketplace import router as marketplace_original_router
|
||||
from app.api.v1.vendor.letzshop import router as letzshop_original_router
|
||||
# Import original routers using importlib to avoid circular imports
|
||||
# (direct import triggers app.api.v1.vendor.__init__.py which imports us)
|
||||
_marketplace_module = importlib.import_module("app.api.v1.vendor.marketplace")
|
||||
_letzshop_module = importlib.import_module("app.api.v1.vendor.letzshop")
|
||||
marketplace_original_router = _marketplace_module.router
|
||||
letzshop_original_router = _letzshop_module.router
|
||||
|
||||
# Create module-aware router for marketplace
|
||||
vendor_router = APIRouter(
|
||||
9
app/modules/marketplace/routes/pages/__init__.py
Normal file
9
app/modules/marketplace/routes/pages/__init__.py
Normal file
@@ -0,0 +1,9 @@
|
||||
# app/modules/marketplace/routes/pages/__init__.py
|
||||
"""
|
||||
Marketplace module page routes (HTML rendering).
|
||||
|
||||
Provides Jinja2 template rendering for marketplace management.
|
||||
Note: Page routes can be added here as needed.
|
||||
"""
|
||||
|
||||
__all__ = []
|
||||
Reference in New Issue
Block a user