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:
@@ -45,6 +45,9 @@ function vendorProfile() {
|
||||
hasChanges: false,
|
||||
|
||||
async init() {
|
||||
// Load i18n translations
|
||||
await I18n.loadModule('tenancy');
|
||||
|
||||
vendorProfileLog.info('Profile init() called');
|
||||
|
||||
// Guard against multiple initialization
|
||||
@@ -153,7 +156,7 @@ function vendorProfile() {
|
||||
*/
|
||||
async saveProfile() {
|
||||
if (!this.validateForm()) {
|
||||
Utils.showToast('Please fix the errors before saving', 'error');
|
||||
Utils.showToast(I18n.t('tenancy.messages.please_fix_the_errors_before_saving'), 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -161,7 +164,7 @@ function vendorProfile() {
|
||||
try {
|
||||
await apiClient.put(`/vendor/profile`, this.form);
|
||||
|
||||
Utils.showToast('Profile updated successfully', 'success');
|
||||
Utils.showToast(I18n.t('tenancy.messages.profile_updated_successfully'), 'success');
|
||||
vendorProfileLog.info('Profile updated');
|
||||
|
||||
this.hasChanges = false;
|
||||
|
||||
25
app/modules/tenancy/static/vendor/js/settings.js
vendored
25
app/modules/tenancy/static/vendor/js/settings.js
vendored
@@ -135,6 +135,9 @@ function vendorSettings() {
|
||||
hasMarketplaceChanges: false,
|
||||
|
||||
async init() {
|
||||
// Load i18n translations
|
||||
await I18n.loadModule('tenancy');
|
||||
|
||||
vendorSettingsLog.info('Settings init() called');
|
||||
|
||||
// Guard against multiple initialization
|
||||
@@ -315,7 +318,7 @@ function vendorSettings() {
|
||||
|
||||
await apiClient.put(`/vendor/settings/business-info`, payload);
|
||||
|
||||
Utils.showToast('Business info saved', 'success');
|
||||
Utils.showToast(I18n.t('tenancy.messages.business_info_saved'), 'success');
|
||||
vendorSettingsLog.info('Business info updated');
|
||||
|
||||
// Reload to get updated inheritance flags
|
||||
@@ -337,7 +340,7 @@ function vendorSettings() {
|
||||
try {
|
||||
await apiClient.put(`/vendor/settings/letzshop`, this.marketplaceForm);
|
||||
|
||||
Utils.showToast('Marketplace settings saved', 'success');
|
||||
Utils.showToast(I18n.t('tenancy.messages.marketplace_settings_saved'), 'success');
|
||||
vendorSettingsLog.info('Marketplace settings updated');
|
||||
|
||||
this.hasMarketplaceChanges = false;
|
||||
@@ -355,7 +358,7 @@ function vendorSettings() {
|
||||
async testLetzshopUrl(lang) {
|
||||
const url = this.marketplaceForm[`letzshop_csv_url_${lang}`];
|
||||
if (!url) {
|
||||
Utils.showToast('Please enter a URL first', 'error');
|
||||
Utils.showToast(I18n.t('tenancy.messages.please_enter_a_url_first'), 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -365,7 +368,7 @@ function vendorSettings() {
|
||||
const response = await fetch(url, { method: 'HEAD', mode: 'no-cors' });
|
||||
Utils.showToast(`URL appears to be valid`, 'success');
|
||||
} catch (error) {
|
||||
Utils.showToast('Could not validate URL - it may still work', 'warning');
|
||||
Utils.showToast(I18n.t('tenancy.messages.could_not_validate_url_it_may_still_work'), 'warning');
|
||||
} finally {
|
||||
this.saving = false;
|
||||
}
|
||||
@@ -406,7 +409,7 @@ function vendorSettings() {
|
||||
try {
|
||||
await apiClient.put(`/vendor/settings/localization`, this.localizationForm);
|
||||
|
||||
Utils.showToast('Localization settings saved', 'success');
|
||||
Utils.showToast(I18n.t('tenancy.messages.localization_settings_saved'), 'success');
|
||||
vendorSettingsLog.info('Localization settings updated');
|
||||
|
||||
this.hasLocalizationChanges = false;
|
||||
@@ -450,7 +453,7 @@ function vendorSettings() {
|
||||
vendorSettingsLog.info('Loaded email settings');
|
||||
} catch (error) {
|
||||
vendorSettingsLog.error('Failed to load email settings:', error);
|
||||
Utils.showToast('Failed to load email settings', 'error');
|
||||
Utils.showToast(I18n.t('tenancy.messages.failed_to_load_email_settings'), 'error');
|
||||
} finally {
|
||||
this.emailSettingsLoading = false;
|
||||
}
|
||||
@@ -500,7 +503,7 @@ function vendorSettings() {
|
||||
async saveEmailSettings() {
|
||||
// Validate required fields
|
||||
if (!this.emailForm.from_email || !this.emailForm.from_name) {
|
||||
Utils.showToast('From Email and From Name are required', 'error');
|
||||
Utils.showToast(I18n.t('tenancy.messages.from_email_and_from_name_are_required'), 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -509,7 +512,7 @@ function vendorSettings() {
|
||||
const response = await apiClient.put('/vendor/email-settings', this.emailForm);
|
||||
|
||||
if (response.success) {
|
||||
Utils.showToast('Email settings saved', 'success');
|
||||
Utils.showToast(I18n.t('tenancy.messages.email_settings_saved'), 'success');
|
||||
vendorSettingsLog.info('Email settings updated');
|
||||
|
||||
// Update local state
|
||||
@@ -531,12 +534,12 @@ function vendorSettings() {
|
||||
*/
|
||||
async sendTestEmail() {
|
||||
if (!this.testEmailAddress) {
|
||||
Utils.showToast('Please enter a test email address', 'error');
|
||||
Utils.showToast(I18n.t('tenancy.messages.please_enter_a_test_email_address'), 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.emailSettings?.is_configured) {
|
||||
Utils.showToast('Please save your email settings first', 'error');
|
||||
Utils.showToast(I18n.t('tenancy.messages.please_save_your_email_settings_first'), 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -547,7 +550,7 @@ function vendorSettings() {
|
||||
});
|
||||
|
||||
if (response.success) {
|
||||
Utils.showToast('Test email sent! Check your inbox.', 'success');
|
||||
Utils.showToast(I18n.t('tenancy.messages.test_email_sent_check_your_inbox'), 'success');
|
||||
// Update verification status
|
||||
this.emailSettings.is_verified = true;
|
||||
} else {
|
||||
|
||||
11
app/modules/tenancy/static/vendor/js/team.js
vendored
11
app/modules/tenancy/static/vendor/js/team.js
vendored
@@ -64,6 +64,9 @@ function vendorTeam() {
|
||||
],
|
||||
|
||||
async init() {
|
||||
// Load i18n translations
|
||||
await I18n.loadModule('tenancy');
|
||||
|
||||
vendorTeamLog.info('Team init() called');
|
||||
|
||||
// Guard against multiple initialization
|
||||
@@ -149,7 +152,7 @@ function vendorTeam() {
|
||||
*/
|
||||
async sendInvitation() {
|
||||
if (!this.inviteForm.email) {
|
||||
Utils.showToast('Email is required', 'error');
|
||||
Utils.showToast(I18n.t('tenancy.messages.email_is_required'), 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -157,7 +160,7 @@ function vendorTeam() {
|
||||
try {
|
||||
await apiClient.post(`/vendor/team/invite`, this.inviteForm);
|
||||
|
||||
Utils.showToast('Invitation sent successfully', 'success');
|
||||
Utils.showToast(I18n.t('tenancy.messages.invitation_sent_successfully'), 'success');
|
||||
vendorTeamLog.info('Invitation sent to:', this.inviteForm.email);
|
||||
|
||||
this.showInviteModal = false;
|
||||
@@ -195,7 +198,7 @@ function vendorTeam() {
|
||||
this.editForm
|
||||
);
|
||||
|
||||
Utils.showToast('Team member updated', 'success');
|
||||
Utils.showToast(I18n.t('tenancy.messages.team_member_updated'), 'success');
|
||||
vendorTeamLog.info('Updated team member:', this.selectedMember.user_id);
|
||||
|
||||
this.showEditModal = false;
|
||||
@@ -227,7 +230,7 @@ function vendorTeam() {
|
||||
try {
|
||||
await apiClient.delete(`/vendor/team/members/${this.selectedMember.user_id}`);
|
||||
|
||||
Utils.showToast('Team member removed', 'success');
|
||||
Utils.showToast(I18n.t('tenancy.messages.team_member_removed'), 'success');
|
||||
vendorTeamLog.info('Removed team member:', this.selectedMember.user_id);
|
||||
|
||||
this.showRemoveModal = false;
|
||||
|
||||
Reference in New Issue
Block a user