Application fully migrated to modular approach
This commit is contained in:
@@ -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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user