Application fully migrated to modular approach

This commit is contained in:
2025-09-13 21:30:40 +02:00
parent c7d6b33cd5
commit b9fe91ab88
38 changed files with 509 additions and 265 deletions

View File

@@ -1,3 +1,4 @@
from sqlalchemy import func
from sqlalchemy.orm import Session
from models.database_models import MarketplaceImportJob, Shop, User
from models.api_models import MarketplaceImportRequest, MarketplaceImportJobResponse
@@ -14,7 +15,11 @@ class MarketplaceService:
def validate_shop_access(self, db: Session, shop_code: str, user: User) -> Shop:
"""Validate that the shop exists and user has access to it"""
shop = db.query(Shop).filter(Shop.shop_code == shop_code).first()
# Explicit type hint to help type checker shop: Optional[Shop]
# Use case-insensitive query to handle both uppercase and lowercase codes
shop: Optional[Shop] = db.query(Shop).filter(
func.upper(Shop.shop_code) == shop_code.upper()
).first()
if not shop:
raise ValueError("Shop not found")