- Rename module definition variables to follow naming convention: - catalog/definition.py: module → catalog_module - checkout/definition.py: module → checkout_module - cart/definition.py: module → cart_module - Add router attachment functions for lazy loading: - get_catalog_module_with_routers() - get_checkout_module_with_routers() - get_cart_module_with_routers() - Move billing exceptions to exceptions.py: - Add backwards-compatible aliases (BillingServiceError, etc.) - Update billing_service.py to import from exceptions.py - Standardize VendorEmailSettingsService DI pattern: - Change from db in __init__ to db as method parameter - Create singleton vendor_email_settings_service instance - Update routes and tests to use new pattern Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
72 lines
2.2 KiB
Python
72 lines
2.2 KiB
Python
# app/modules/cart/definition.py
|
|
"""
|
|
Cart module definition.
|
|
|
|
This module provides shopping cart functionality for customer storefronts.
|
|
It is session-based and does not require customer authentication.
|
|
"""
|
|
|
|
from app.modules.base import ModuleDefinition, PermissionDefinition
|
|
|
|
|
|
# =============================================================================
|
|
# Router Lazy Imports
|
|
# =============================================================================
|
|
|
|
|
|
def _get_storefront_router():
|
|
"""Lazy import of storefront router to avoid circular imports."""
|
|
from app.modules.cart.routes.api.storefront import router
|
|
|
|
return router
|
|
|
|
|
|
# Cart module definition
|
|
cart_module = ModuleDefinition(
|
|
code="cart",
|
|
name="Shopping Cart",
|
|
description="Session-based shopping cart for storefronts",
|
|
version="1.0.0",
|
|
is_self_contained=True,
|
|
requires=["inventory"], # Checks inventory availability
|
|
features=[
|
|
"cart_management", # Basic cart CRUD operations
|
|
"cart_persistence", # Session and database persistence
|
|
"cart_item_operations", # Add, update, remove items
|
|
"shipping_calculation", # Calculate shipping for cart
|
|
"promotion_application", # Apply discounts and promotions
|
|
],
|
|
# Note: Cart is primarily session-based storefront functionality.
|
|
# These permissions are for admin access to cart data/settings.
|
|
permissions=[
|
|
PermissionDefinition(
|
|
id="cart.view",
|
|
label_key="cart.permissions.view",
|
|
description_key="cart.permissions.view_desc",
|
|
category="cart",
|
|
),
|
|
PermissionDefinition(
|
|
id="cart.manage",
|
|
label_key="cart.permissions.manage",
|
|
description_key="cart.permissions.manage_desc",
|
|
category="cart",
|
|
),
|
|
],
|
|
# Cart is storefront-only - no admin/vendor menus needed
|
|
menu_items={},
|
|
)
|
|
|
|
|
|
def get_cart_module_with_routers() -> ModuleDefinition:
|
|
"""
|
|
Get cart module with routers attached.
|
|
|
|
This function attaches the routers lazily to avoid circular imports
|
|
during module initialization.
|
|
"""
|
|
cart_module.storefront_router = _get_storefront_router()
|
|
return cart_module
|
|
|
|
|
|
__all__ = ["cart_module", "get_cart_module_with_routers"]
|