fix: resolve circular import in module system

The circular import occurred because:
1. app.modules.base imported FrontendType from models.database.admin_menu_config
2. This triggered models/database/__init__.py which runs model discovery
3. Model discovery imported module definitions
4. Module definitions imported from app.modules.base (still initializing)

Solution: Move FrontendType and MANDATORY_MENU_ITEMS to a new
app/modules/enums.py file. The models file re-exports them for
backward compatibility with existing imports.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-31 21:21:07 +01:00
parent 66f9600286
commit 6d7accfa25
3 changed files with 52 additions and 27 deletions

View File

@@ -19,8 +19,6 @@ Design:
- Only stores non-default state (is_visible=False) to keep table small
"""
import enum
from sqlalchemy import (
Boolean,
CheckConstraint,
@@ -37,30 +35,11 @@ from sqlalchemy.orm import relationship
from app.core.database import Base
from models.database.base import TimestampMixin
class FrontendType(str, enum.Enum):
"""Frontend types that can have menu configuration."""
ADMIN = "admin" # Admin panel (super admins, platform admins)
VENDOR = "vendor" # Vendor dashboard
# Menu items that cannot be hidden - always visible regardless of config
# Organized by frontend type
MANDATORY_MENU_ITEMS = {
FrontendType.ADMIN: frozenset({
"dashboard", # Default landing page after login
"companies",
"vendors",
"admin-users",
"settings",
"my-menu", # Super admin menu config - must always be accessible
}),
FrontendType.VENDOR: frozenset({
"dashboard", # Default landing page after login
"settings",
}),
}
# Import FrontendType and MANDATORY_MENU_ITEMS from the central location
# and re-export for backward compatibility with existing imports.
# These were moved to app.modules.enums to break a circular import:
# app.modules.base -> models.database -> model discovery -> module definitions -> app.modules.base
from app.modules.enums import FrontendType, MANDATORY_MENU_ITEMS
class AdminMenuConfig(Base, TimestampMixin):