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:
@@ -2,7 +2,10 @@
|
||||
"""
|
||||
Catalog module exceptions.
|
||||
|
||||
Module-specific exceptions for product catalog operations.
|
||||
This module provides exception classes for catalog operations including:
|
||||
- Product management (CRUD)
|
||||
- Product validation
|
||||
- Product dependencies (inventory, orders)
|
||||
"""
|
||||
|
||||
from app.exceptions.base import (
|
||||
@@ -12,6 +15,19 @@ from app.exceptions.base import (
|
||||
ValidationException,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"ProductNotFoundException",
|
||||
"ProductAlreadyExistsException",
|
||||
"ProductNotInCatalogException",
|
||||
"ProductNotActiveException",
|
||||
"InvalidProductDataException",
|
||||
"ProductValidationException",
|
||||
"CannotDeleteProductException",
|
||||
"CannotDeleteProductWithInventoryException",
|
||||
"CannotDeleteProductWithOrdersException",
|
||||
"ProductMediaException",
|
||||
]
|
||||
|
||||
|
||||
class ProductNotFoundException(ResourceNotFoundException):
|
||||
"""Raised when a product is not found in vendor catalog."""
|
||||
@@ -56,11 +72,9 @@ class ProductNotInCatalogException(ResourceNotFoundException):
|
||||
identifier=str(product_id),
|
||||
message=f"Product {product_id} is not in vendor {vendor_id} catalog",
|
||||
error_code="PRODUCT_NOT_IN_CATALOG",
|
||||
details={
|
||||
"product_id": product_id,
|
||||
"vendor_id": vendor_id,
|
||||
},
|
||||
)
|
||||
self.details["product_id"] = product_id
|
||||
self.details["vendor_id"] = vendor_id
|
||||
|
||||
|
||||
class ProductNotActiveException(BusinessLogicException):
|
||||
@@ -77,6 +91,23 @@ class ProductNotActiveException(BusinessLogicException):
|
||||
)
|
||||
|
||||
|
||||
class InvalidProductDataException(ValidationException):
|
||||
"""Raised when product data is invalid."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
message: str = "Invalid product data",
|
||||
field: str | None = None,
|
||||
details: dict | None = None,
|
||||
):
|
||||
super().__init__(
|
||||
message=message,
|
||||
field=field,
|
||||
details=details,
|
||||
)
|
||||
self.error_code = "INVALID_PRODUCT_DATA"
|
||||
|
||||
|
||||
class ProductValidationException(ValidationException):
|
||||
"""Raised when product data validation fails."""
|
||||
|
||||
@@ -109,6 +140,34 @@ class CannotDeleteProductException(BusinessLogicException):
|
||||
)
|
||||
|
||||
|
||||
class CannotDeleteProductWithInventoryException(BusinessLogicException):
|
||||
"""Raised when trying to delete a product that has inventory."""
|
||||
|
||||
def __init__(self, product_id: int, inventory_count: int):
|
||||
super().__init__(
|
||||
message=f"Cannot delete product {product_id} - it has {inventory_count} inventory entries",
|
||||
error_code="CANNOT_DELETE_PRODUCT_WITH_INVENTORY",
|
||||
details={
|
||||
"product_id": product_id,
|
||||
"inventory_count": inventory_count,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
class CannotDeleteProductWithOrdersException(BusinessLogicException):
|
||||
"""Raised when trying to delete a product that has been ordered."""
|
||||
|
||||
def __init__(self, product_id: int, order_count: int):
|
||||
super().__init__(
|
||||
message=f"Cannot delete product {product_id} - it has {order_count} associated orders",
|
||||
error_code="CANNOT_DELETE_PRODUCT_WITH_ORDERS",
|
||||
details={
|
||||
"product_id": product_id,
|
||||
"order_count": order_count,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
class ProductMediaException(BusinessLogicException):
|
||||
"""Raised when there's an issue with product media."""
|
||||
|
||||
@@ -118,14 +177,3 @@ class ProductMediaException(BusinessLogicException):
|
||||
error_code="PRODUCT_MEDIA_ERROR",
|
||||
details={"product_id": product_id},
|
||||
)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"CannotDeleteProductException",
|
||||
"ProductAlreadyExistsException",
|
||||
"ProductMediaException",
|
||||
"ProductNotActiveException",
|
||||
"ProductNotFoundException",
|
||||
"ProductNotInCatalogException",
|
||||
"ProductValidationException",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user