refactor: implement module-driven permissions and relocate business logic
File Relocations: - Delete app/config/ folder (empty after menu_registry removal) - Move feature_gate.py → app/modules/billing/dependencies/ - Move theme_presets.py → app/modules/cms/services/ Module-Driven Permissions System: - Add PermissionDefinition dataclass to app/modules/base.py - Create PermissionDiscoveryService in tenancy module - Update module definitions to declare their own permissions: - core: dashboard.view, settings.* - catalog: products.* - orders: orders.* - inventory: stock.* - customers: customers.* - tenancy: team.* - Update app/core/permissions.py to use discovery service - Role presets (owner, manager, staff, etc.) now use module permissions This follows the same pattern as module-driven menus: - Each module defines its permissions in definition.py - PermissionDiscoveryService aggregates all permissions at runtime - Tenancy module handles role-to-permission assignment Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,7 +6,12 @@ Defines the customers module including its features, menu items,
|
||||
route configurations, and self-contained module settings.
|
||||
"""
|
||||
|
||||
from app.modules.base import MenuItemDefinition, MenuSectionDefinition, ModuleDefinition
|
||||
from app.modules.base import (
|
||||
MenuItemDefinition,
|
||||
MenuSectionDefinition,
|
||||
ModuleDefinition,
|
||||
PermissionDefinition,
|
||||
)
|
||||
from app.modules.enums import FrontendType
|
||||
|
||||
|
||||
@@ -30,6 +35,33 @@ customers_module = ModuleDefinition(
|
||||
name="Customer Management",
|
||||
description="Customer database, profiles, addresses, and segmentation.",
|
||||
version="1.0.0",
|
||||
# Module-driven permissions
|
||||
permissions=[
|
||||
PermissionDefinition(
|
||||
id="customers.view",
|
||||
label_key="customers.permissions.customers_view",
|
||||
description_key="customers.permissions.customers_view_desc",
|
||||
category="customers",
|
||||
),
|
||||
PermissionDefinition(
|
||||
id="customers.edit",
|
||||
label_key="customers.permissions.customers_edit",
|
||||
description_key="customers.permissions.customers_edit_desc",
|
||||
category="customers",
|
||||
),
|
||||
PermissionDefinition(
|
||||
id="customers.delete",
|
||||
label_key="customers.permissions.customers_delete",
|
||||
description_key="customers.permissions.customers_delete_desc",
|
||||
category="customers",
|
||||
),
|
||||
PermissionDefinition(
|
||||
id="customers.export",
|
||||
label_key="customers.permissions.customers_export",
|
||||
description_key="customers.permissions.customers_export_desc",
|
||||
category="customers",
|
||||
),
|
||||
],
|
||||
features=[
|
||||
"customer_view", # View customer profiles
|
||||
"customer_export", # Export customer data
|
||||
|
||||
Reference in New Issue
Block a user