fix: resolve all remaining legacy import issues
- Update models/database/__init__.py to import from module locations - Update models/schema/__init__.py to remove deleted modules - Update models/__init__.py to import Inventory from module - Remove duplicate AdminNotification from models/database/admin.py - Fix monitoring module to import AdminNotification from messaging - Update stats schema imports in admin/vendor API - Update notification schema imports - Add order_item_exception.py schema to orders module - Fix app/api/v1/__init__.py to use storefront instead of shop - Add cms_admin_pages import to main.py - Fix password_reset_token imports - Fix AdminNotification test imports Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,6 @@
|
||||
API Version 1 - All endpoints
|
||||
"""
|
||||
|
||||
from . import admin, shop, vendor
|
||||
from . import admin, storefront, vendor
|
||||
|
||||
__all__ = ["admin", "vendor", "shop"]
|
||||
__all__ = ["admin", "vendor", "storefront"]
|
||||
|
||||
@@ -21,7 +21,7 @@ from app.services.code_quality_service import (
|
||||
from app.tasks.code_quality_tasks import execute_code_quality_scan
|
||||
from models.database.architecture_scan import ArchitectureScan
|
||||
from models.database.user import User
|
||||
from models.schema.stats import CodeQualityDashboardStatsResponse
|
||||
from app.modules.analytics.schemas import CodeQualityDashboardStatsResponse
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ from app.core.database import get_db
|
||||
from app.services.admin_service import admin_service
|
||||
from app.services.stats_service import stats_service
|
||||
from models.database.user import User
|
||||
from models.schema.stats import (
|
||||
from app.modules.analytics.schemas import (
|
||||
AdminDashboardResponse,
|
||||
ImportStatsResponse,
|
||||
MarketplaceStatsResponse,
|
||||
|
||||
@@ -24,7 +24,7 @@ from models.schema.marketplace_import_job import (
|
||||
MarketplaceImportJobRequest,
|
||||
MarketplaceImportJobResponse,
|
||||
)
|
||||
from models.schema.stats import ImportStatsResponse
|
||||
from app.modules.analytics.schemas import ImportStatsResponse
|
||||
|
||||
router = APIRouter(prefix="/marketplace-import-jobs")
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -29,7 +29,7 @@ from models.schema.admin import (
|
||||
PlatformAlertResolve,
|
||||
PlatformAlertResponse,
|
||||
)
|
||||
from models.schema.notification import (
|
||||
from app.modules.messaging.schemas import (
|
||||
AlertStatisticsResponse,
|
||||
MessageResponse,
|
||||
UnreadCountResponse,
|
||||
|
||||
@@ -20,7 +20,7 @@ from app.services.admin_service import admin_service
|
||||
from app.services.stats_service import stats_service
|
||||
from app.services.vendor_service import vendor_service
|
||||
from models.database.user import User
|
||||
from models.schema.stats import VendorStatsResponse
|
||||
from app.modules.analytics.schemas import VendorStatsResponse
|
||||
from models.schema.vendor import (
|
||||
LetzshopExportRequest,
|
||||
LetzshopExportResponse,
|
||||
|
||||
2
app/api/v1/vendor/analytics.py
vendored
2
app/api/v1/vendor/analytics.py
vendored
@@ -21,7 +21,7 @@ from app.core.feature_gate import RequireFeature
|
||||
from app.services.stats_service import stats_service
|
||||
from models.database.feature import FeatureCode
|
||||
from models.database.user import User
|
||||
from models.schema.stats import (
|
||||
from app.modules.analytics.schemas import (
|
||||
VendorAnalyticsCatalog,
|
||||
VendorAnalyticsImports,
|
||||
VendorAnalyticsInventory,
|
||||
|
||||
2
app/api/v1/vendor/dashboard.py
vendored
2
app/api/v1/vendor/dashboard.py
vendored
@@ -17,7 +17,7 @@ from app.exceptions import VendorNotActiveException
|
||||
from app.services.stats_service import stats_service
|
||||
from app.services.vendor_service import vendor_service
|
||||
from models.database.user import User
|
||||
from models.schema.stats import (
|
||||
from app.modules.analytics.schemas import (
|
||||
VendorCustomerStats,
|
||||
VendorDashboardStatsResponse,
|
||||
VendorInfo,
|
||||
|
||||
2
app/api/v1/vendor/notifications.py
vendored
2
app/api/v1/vendor/notifications.py
vendored
@@ -15,7 +15,7 @@ from app.api.deps import get_current_vendor_api
|
||||
from app.core.database import get_db
|
||||
from app.services.vendor_service import vendor_service
|
||||
from models.database.user import User
|
||||
from models.schema.notification import (
|
||||
from app.modules.messaging.schemas import (
|
||||
MessageResponse,
|
||||
NotificationListResponse,
|
||||
NotificationSettingsResponse,
|
||||
|
||||
@@ -31,7 +31,7 @@ from app.modules.customers.services import (
|
||||
)
|
||||
from app.services.auth_service import AuthService
|
||||
from app.services.email_service import EmailService
|
||||
from models.database.password_reset_token import PasswordResetToken
|
||||
from app.modules.customers.models import PasswordResetToken
|
||||
from models.schema.auth import (
|
||||
LogoutResponse,
|
||||
PasswordResetRequestResponse,
|
||||
|
||||
@@ -9,10 +9,8 @@ Re-exports monitoring-related models from their source locations.
|
||||
from app.modules.billing.models import CapacitySnapshot
|
||||
|
||||
# Admin notification and logging models
|
||||
from models.database.admin import (
|
||||
AdminNotification,
|
||||
PlatformAlert,
|
||||
)
|
||||
from app.modules.messaging.models import AdminNotification
|
||||
from models.database.admin import PlatformAlert
|
||||
|
||||
__all__ = [
|
||||
"CapacitySnapshot",
|
||||
|
||||
@@ -43,6 +43,18 @@ from app.modules.orders.schemas.order import (
|
||||
ShippingLabelInfo,
|
||||
)
|
||||
|
||||
from app.modules.orders.schemas.order_item_exception import (
|
||||
OrderItemExceptionResponse,
|
||||
OrderItemExceptionBriefResponse,
|
||||
OrderItemExceptionListResponse,
|
||||
OrderItemExceptionStats,
|
||||
ResolveExceptionRequest,
|
||||
IgnoreExceptionRequest,
|
||||
BulkResolveRequest,
|
||||
BulkResolveResponse,
|
||||
AutoMatchResult,
|
||||
)
|
||||
|
||||
from app.modules.orders.schemas.invoice import (
|
||||
# Invoice settings schemas
|
||||
VendorInvoiceSettingsCreate,
|
||||
@@ -79,6 +91,16 @@ __all__ = [
|
||||
"OrderItemCreate",
|
||||
"OrderItemExceptionBrief",
|
||||
"OrderItemResponse",
|
||||
# Order item exception schemas
|
||||
"OrderItemExceptionResponse",
|
||||
"OrderItemExceptionBriefResponse",
|
||||
"OrderItemExceptionListResponse",
|
||||
"OrderItemExceptionStats",
|
||||
"ResolveExceptionRequest",
|
||||
"IgnoreExceptionRequest",
|
||||
"BulkResolveRequest",
|
||||
"BulkResolveResponse",
|
||||
"AutoMatchResult",
|
||||
# Customer schemas
|
||||
"CustomerSnapshot",
|
||||
"CustomerSnapshotResponse",
|
||||
|
||||
173
app/modules/orders/schemas/order_item_exception.py
Normal file
173
app/modules/orders/schemas/order_item_exception.py
Normal file
@@ -0,0 +1,173 @@
|
||||
# app/modules/orders/schemas/order_item_exception.py
|
||||
"""
|
||||
Pydantic schemas for order item exception management.
|
||||
|
||||
Handles unmatched products during marketplace order imports.
|
||||
"""
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# Exception Response Schemas
|
||||
# ============================================================================
|
||||
|
||||
|
||||
class OrderItemExceptionResponse(BaseModel):
|
||||
"""Schema for order item exception response."""
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
id: int
|
||||
order_item_id: int
|
||||
vendor_id: int
|
||||
vendor_name: str | None = None # For cross-vendor views
|
||||
|
||||
# Original data from marketplace
|
||||
original_gtin: str | None
|
||||
original_product_name: str | None
|
||||
original_sku: str | None
|
||||
|
||||
# Exception classification
|
||||
exception_type: str # product_not_found, gtin_mismatch, duplicate_gtin
|
||||
|
||||
# Resolution status
|
||||
status: str # pending, resolved, ignored
|
||||
|
||||
# Resolution details
|
||||
resolved_product_id: int | None
|
||||
resolved_at: datetime | None
|
||||
resolved_by: int | None
|
||||
resolution_notes: str | None
|
||||
|
||||
# Timestamps
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
# Nested order info (populated by service)
|
||||
order_number: str | None = None
|
||||
order_id: int | None = None
|
||||
order_date: datetime | None = None
|
||||
order_status: str | None = None
|
||||
|
||||
@property
|
||||
def is_pending(self) -> bool:
|
||||
"""Check if exception is pending resolution."""
|
||||
return self.status == "pending"
|
||||
|
||||
@property
|
||||
def is_resolved(self) -> bool:
|
||||
"""Check if exception has been resolved."""
|
||||
return self.status == "resolved"
|
||||
|
||||
@property
|
||||
def is_ignored(self) -> bool:
|
||||
"""Check if exception has been ignored."""
|
||||
return self.status == "ignored"
|
||||
|
||||
|
||||
class OrderItemExceptionBriefResponse(BaseModel):
|
||||
"""Brief exception info for embedding in order item responses."""
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
id: int
|
||||
original_gtin: str | None
|
||||
original_product_name: str | None
|
||||
exception_type: str
|
||||
status: str
|
||||
resolved_product_id: int | None
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# List/Stats Response Schemas
|
||||
# ============================================================================
|
||||
|
||||
|
||||
class OrderItemExceptionListResponse(BaseModel):
|
||||
"""Paginated list of exceptions."""
|
||||
|
||||
exceptions: list[OrderItemExceptionResponse]
|
||||
total: int
|
||||
skip: int
|
||||
limit: int
|
||||
|
||||
|
||||
class OrderItemExceptionStats(BaseModel):
|
||||
"""Exception statistics for a vendor."""
|
||||
|
||||
pending: int = 0
|
||||
resolved: int = 0
|
||||
ignored: int = 0
|
||||
total: int = 0
|
||||
|
||||
# Additional breakdown
|
||||
orders_with_exceptions: int = 0
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# Request Schemas
|
||||
# ============================================================================
|
||||
|
||||
|
||||
class ResolveExceptionRequest(BaseModel):
|
||||
"""Request to resolve an exception by assigning a product."""
|
||||
|
||||
product_id: int = Field(..., description="Product ID to assign to this order item")
|
||||
notes: str | None = Field(
|
||||
None,
|
||||
max_length=1000,
|
||||
description="Optional notes about the resolution"
|
||||
)
|
||||
|
||||
|
||||
class IgnoreExceptionRequest(BaseModel):
|
||||
"""Request to ignore an exception (still blocks confirmation)."""
|
||||
|
||||
notes: str = Field(
|
||||
...,
|
||||
min_length=1,
|
||||
max_length=1000,
|
||||
description="Reason for ignoring (required)"
|
||||
)
|
||||
|
||||
|
||||
class BulkResolveRequest(BaseModel):
|
||||
"""Request to bulk resolve all pending exceptions for a GTIN."""
|
||||
|
||||
gtin: str = Field(
|
||||
...,
|
||||
min_length=1,
|
||||
max_length=50,
|
||||
description="GTIN to match pending exceptions"
|
||||
)
|
||||
product_id: int = Field(..., description="Product ID to assign")
|
||||
notes: str | None = Field(
|
||||
None,
|
||||
max_length=1000,
|
||||
description="Optional notes about the resolution"
|
||||
)
|
||||
|
||||
|
||||
class BulkResolveResponse(BaseModel):
|
||||
"""Response from bulk resolve operation."""
|
||||
|
||||
resolved_count: int
|
||||
gtin: str
|
||||
product_id: int
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# Auto-Match Response Schemas
|
||||
# ============================================================================
|
||||
|
||||
|
||||
class AutoMatchResult(BaseModel):
|
||||
"""Result of auto-matching after product import."""
|
||||
|
||||
gtin: str
|
||||
product_id: int
|
||||
resolved_count: int
|
||||
resolved_exception_ids: list[int]
|
||||
Reference in New Issue
Block a user