refactor: complete module-driven architecture migration
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>
This commit is contained in:
@@ -29,6 +29,9 @@ function adminUserEditPage() {
|
||||
|
||||
// Initialize
|
||||
async init() {
|
||||
// Load i18n translations
|
||||
await I18n.loadModule('tenancy');
|
||||
|
||||
adminUserEditLog.info('=== ADMIN USER EDIT PAGE INITIALIZING ===');
|
||||
|
||||
// Prevent multiple initializations
|
||||
@@ -52,7 +55,7 @@ function adminUserEditPage() {
|
||||
await this.loadAllPlatforms();
|
||||
} else {
|
||||
adminUserEditLog.error('No user ID in URL');
|
||||
Utils.showToast('Invalid admin user URL', 'error');
|
||||
Utils.showToast(I18n.t('tenancy.messages.invalid_admin_user_url'), 'error');
|
||||
setTimeout(() => window.location.href = '/admin/admin-users', 2000);
|
||||
}
|
||||
|
||||
@@ -94,7 +97,7 @@ function adminUserEditPage() {
|
||||
|
||||
} catch (error) {
|
||||
window.LogConfig.logError(error, 'Load Admin User');
|
||||
Utils.showToast('Failed to load admin user', 'error');
|
||||
Utils.showToast(I18n.t('tenancy.messages.failed_to_load_admin_user'), 'error');
|
||||
setTimeout(() => window.location.href = '/admin/admin-users', 2000);
|
||||
} finally {
|
||||
this.loading = false;
|
||||
@@ -137,7 +140,7 @@ function adminUserEditPage() {
|
||||
|
||||
// Prevent self-demotion
|
||||
if (this.adminUser.id === this.currentUserId && !newStatus) {
|
||||
Utils.showToast('You cannot demote yourself from super admin', 'error');
|
||||
Utils.showToast(I18n.t('tenancy.messages.you_cannot_demote_yourself_from_super_ad'), 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -180,7 +183,7 @@ function adminUserEditPage() {
|
||||
|
||||
// Prevent self-deactivation
|
||||
if (this.adminUser.id === this.currentUserId) {
|
||||
Utils.showToast('You cannot deactivate your own account', 'error');
|
||||
Utils.showToast(I18n.t('tenancy.messages.you_cannot_deactivate_your_own_account'), 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -228,7 +231,7 @@ function adminUserEditPage() {
|
||||
// Reload admin user to get updated platforms
|
||||
await this.loadAdminUser();
|
||||
|
||||
Utils.showToast('Platform assigned successfully', 'success');
|
||||
Utils.showToast(I18n.t('tenancy.messages.platform_assigned_successfully'), 'success');
|
||||
adminUserEditLog.info('Platform assigned successfully');
|
||||
this.showPlatformModal = false;
|
||||
this.selectedPlatformId = null;
|
||||
@@ -245,7 +248,7 @@ function adminUserEditPage() {
|
||||
removePlatform(platformId) {
|
||||
// Validate: platform admin must have at least one platform
|
||||
if (this.adminUser.platforms.length <= 1) {
|
||||
Utils.showToast('Platform admin must be assigned to at least one platform', 'error');
|
||||
Utils.showToast(I18n.t('tenancy.messages.platform_admin_must_be_assigned_to_at_le'), 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -272,7 +275,7 @@ function adminUserEditPage() {
|
||||
// Reload admin user to get updated platforms
|
||||
await this.loadAdminUser();
|
||||
|
||||
Utils.showToast('Platform removed successfully', 'success');
|
||||
Utils.showToast(I18n.t('tenancy.messages.platform_removed_successfully'), 'success');
|
||||
adminUserEditLog.info('Platform removed successfully');
|
||||
|
||||
} catch (error) {
|
||||
@@ -296,7 +299,7 @@ function adminUserEditPage() {
|
||||
|
||||
// Prevent self-deletion
|
||||
if (this.adminUser.id === this.currentUserId) {
|
||||
Utils.showToast('You cannot delete your own account', 'error');
|
||||
Utils.showToast(I18n.t('tenancy.messages.you_cannot_delete_your_own_account'), 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -320,7 +323,7 @@ function adminUserEditPage() {
|
||||
|
||||
window.LogConfig.logApiCall('DELETE', url, null, 'response');
|
||||
|
||||
Utils.showToast('Admin user deleted successfully', 'success');
|
||||
Utils.showToast(I18n.t('tenancy.messages.admin_user_deleted_successfully'), 'success');
|
||||
adminUserEditLog.info('Admin user deleted successfully');
|
||||
|
||||
// Redirect to admin users list
|
||||
|
||||
Reference in New Issue
Block a user