style: apply black and isort formatting across entire codebase

- Standardize quote style (single to double quotes)
- Reorder and group imports alphabetically
- Fix line breaks and indentation for consistency
- Apply PEP 8 formatting standards

Also updated Makefile to exclude both venv and .venv from code quality checks.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-28 19:30:17 +01:00
parent 13f0094743
commit 21c13ca39b
236 changed files with 8450 additions and 6545 deletions

View File

@@ -11,9 +11,10 @@ Class-based middleware provides:
"""
import logging
from starlette.middleware.base import BaseHTTPMiddleware
from fastapi import Request
from sqlalchemy.orm import Session
from starlette.middleware.base import BaseHTTPMiddleware
from app.core.database import get_db
from models.database.vendor_theme import VendorTheme
@@ -30,10 +31,11 @@ class ThemeContextManager:
Get theme configuration for vendor.
Returns default theme if no custom theme is configured.
"""
theme = db.query(VendorTheme).filter(
VendorTheme.vendor_id == vendor_id,
VendorTheme.is_active == True
).first()
theme = (
db.query(VendorTheme)
.filter(VendorTheme.vendor_id == vendor_id, VendorTheme.is_active == True)
.first()
)
if theme:
return theme.to_dict()
@@ -52,23 +54,16 @@ class ThemeContextManager:
"accent": "#ec4899",
"background": "#ffffff",
"text": "#1f2937",
"border": "#e5e7eb"
},
"fonts": {
"heading": "Inter, sans-serif",
"body": "Inter, sans-serif"
"border": "#e5e7eb",
},
"fonts": {"heading": "Inter, sans-serif", "body": "Inter, sans-serif"},
"branding": {
"logo": None,
"logo_dark": None,
"favicon": None,
"banner": None
},
"layout": {
"style": "grid",
"header": "fixed",
"product_card": "modern"
"banner": None,
},
"layout": {"style": "grid", "header": "fixed", "product_card": "modern"},
"social_links": {},
"custom_css": None,
"css_variables": {
@@ -80,7 +75,7 @@ class ThemeContextManager:
"--color-border": "#e5e7eb",
"--font-heading": "Inter, sans-serif",
"--font-body": "Inter, sans-serif",
}
},
}
@@ -106,7 +101,7 @@ class ThemeContextMiddleware(BaseHTTPMiddleware):
Load and inject theme context.
"""
# Only inject theme for shop pages (not admin or API)
if hasattr(request.state, 'vendor') and request.state.vendor:
if hasattr(request.state, "vendor") and request.state.vendor:
vendor = request.state.vendor
# Get database session
@@ -123,13 +118,13 @@ class ThemeContextMiddleware(BaseHTTPMiddleware):
extra={
"vendor_id": vendor.id,
"vendor_name": vendor.name,
"theme_name": theme.get('theme_name', 'default'),
}
"theme_name": theme.get("theme_name", "default"),
},
)
except Exception as e:
logger.error(
f"[THEME] Failed to load theme for vendor {vendor.id}: {e}",
exc_info=True
exc_info=True,
)
# Fallback to default theme
request.state.theme = ThemeContextManager.get_default_theme()
@@ -140,7 +135,7 @@ class ThemeContextMiddleware(BaseHTTPMiddleware):
request.state.theme = ThemeContextManager.get_default_theme()
logger.debug(
"[THEME] No vendor context, using default theme",
extra={"has_vendor": False}
extra={"has_vendor": False},
)
# Continue processing