This commit completes the migration to a fully module-driven architecture: ## Models Migration - Moved all domain models from models/database/ to their respective modules: - tenancy: User, Admin, Vendor, Company, Platform, VendorDomain, etc. - cms: MediaFile, VendorTheme - messaging: Email, VendorEmailSettings, VendorEmailTemplate - core: AdminMenuConfig - models/database/ now only contains Base and TimestampMixin (infrastructure) ## Schemas Migration - Moved all domain schemas from models/schema/ to their respective modules: - tenancy: company, vendor, admin, team, vendor_domain - cms: media, image, vendor_theme - messaging: email - models/schema/ now only contains base.py and auth.py (infrastructure) ## Routes Migration - Moved admin routes from app/api/v1/admin/ to modules: - menu_config.py -> core module - modules.py -> tenancy module - module_config.py -> tenancy module - app/api/v1/admin/ now only aggregates auto-discovered module routes ## Menu System - Implemented module-driven menu system with MenuDiscoveryService - Extended FrontendType enum: PLATFORM, ADMIN, VENDOR, STOREFRONT - Added MenuItemDefinition and MenuSectionDefinition dataclasses - Each module now defines its own menu items in definition.py - MenuService integrates with MenuDiscoveryService for template rendering ## Documentation - Updated docs/architecture/models-structure.md - Updated docs/architecture/menu-management.md - Updated architecture validation rules for new exceptions ## Architecture Validation - Updated MOD-019 rule to allow base.py in models/schema/ - Created core module exceptions.py and schemas/ directory - All validation errors resolved (only warnings remain) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
122 lines
3.9 KiB
Python
122 lines
3.9 KiB
Python
# app/modules/tenancy/definition.py
|
|
"""
|
|
Tenancy Management module definition.
|
|
|
|
Platform, company, vendor, and admin user management.
|
|
Required for multi-tenant operation - cannot be disabled.
|
|
"""
|
|
|
|
from app.modules.base import MenuItemDefinition, MenuSectionDefinition, ModuleDefinition
|
|
from app.modules.enums import FrontendType
|
|
|
|
tenancy_module = ModuleDefinition(
|
|
code="tenancy",
|
|
name="Tenancy Management",
|
|
description="Platform, company, vendor, and admin user management. Required for multi-tenant operation.",
|
|
version="1.0.0",
|
|
is_core=True,
|
|
is_self_contained=True,
|
|
features=[
|
|
"platform_management",
|
|
"company_management",
|
|
"vendor_management",
|
|
"admin_user_management",
|
|
],
|
|
# Legacy menu_items
|
|
menu_items={
|
|
FrontendType.ADMIN: [
|
|
"platforms",
|
|
"companies",
|
|
"vendors",
|
|
"admin-users",
|
|
],
|
|
FrontendType.VENDOR: [
|
|
"team",
|
|
],
|
|
},
|
|
# New module-driven menu definitions
|
|
menus={
|
|
FrontendType.ADMIN: [
|
|
MenuSectionDefinition(
|
|
id="superAdmin",
|
|
label_key="tenancy.menu.super_admin",
|
|
icon="shield",
|
|
order=10,
|
|
is_super_admin_only=True,
|
|
items=[
|
|
MenuItemDefinition(
|
|
id="admin-users",
|
|
label_key="tenancy.menu.admin_users",
|
|
icon="shield",
|
|
route="/admin/admin-users",
|
|
order=10,
|
|
is_mandatory=True,
|
|
),
|
|
],
|
|
),
|
|
MenuSectionDefinition(
|
|
id="platformAdmin",
|
|
label_key="tenancy.menu.platform_admin",
|
|
icon="office-building",
|
|
order=20,
|
|
items=[
|
|
MenuItemDefinition(
|
|
id="companies",
|
|
label_key="tenancy.menu.companies",
|
|
icon="office-building",
|
|
route="/admin/companies",
|
|
order=10,
|
|
is_mandatory=True,
|
|
),
|
|
MenuItemDefinition(
|
|
id="vendors",
|
|
label_key="tenancy.menu.vendors",
|
|
icon="shopping-bag",
|
|
route="/admin/vendors",
|
|
order=20,
|
|
is_mandatory=True,
|
|
),
|
|
],
|
|
),
|
|
MenuSectionDefinition(
|
|
id="contentMgmt",
|
|
label_key="tenancy.menu.content_management",
|
|
icon="globe-alt",
|
|
order=70,
|
|
items=[
|
|
MenuItemDefinition(
|
|
id="platforms",
|
|
label_key="tenancy.menu.platforms",
|
|
icon="globe-alt",
|
|
route="/admin/platforms",
|
|
order=10,
|
|
),
|
|
],
|
|
),
|
|
],
|
|
FrontendType.VENDOR: [
|
|
MenuSectionDefinition(
|
|
id="account",
|
|
label_key="tenancy.menu.account_settings",
|
|
icon="user-group",
|
|
order=900,
|
|
items=[
|
|
MenuItemDefinition(
|
|
id="team",
|
|
label_key="tenancy.menu.team",
|
|
icon="user-group",
|
|
route="/vendor/{vendor_code}/team",
|
|
order=5,
|
|
),
|
|
],
|
|
),
|
|
],
|
|
},
|
|
services_path="app.modules.tenancy.services",
|
|
models_path="app.modules.tenancy.models",
|
|
schemas_path="app.modules.tenancy.schemas",
|
|
exceptions_path="app.modules.tenancy.exceptions",
|
|
)
|
|
|
|
__all__ = ["tenancy_module"]
|