fix: correct tojson|safe usage in templates and update validator
- Remove |safe from |tojson in HTML attributes (x-data) - quotes must become " for browsers to parse correctly - Update LANG-002 and LANG-003 architecture rules to document correct |tojson usage patterns: - HTML attributes: |tojson (no |safe) - Script blocks: |tojson|safe - Fix validator to warn when |tojson|safe is used in x-data (breaks HTML attribute parsing) - Improve code quality across services, APIs, and tests 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -489,10 +489,18 @@ class LogSettingsResponse(BaseModel):
|
||||
class LogSettingsUpdate(BaseModel):
|
||||
"""Update log settings."""
|
||||
|
||||
log_level: str | None = Field(None, description="Log level: DEBUG, INFO, WARNING, ERROR, CRITICAL")
|
||||
log_file_max_size_mb: int | None = Field(None, ge=1, le=1000, description="Max log file size in MB")
|
||||
log_file_backup_count: int | None = Field(None, ge=0, le=50, description="Number of backup files to keep")
|
||||
db_log_retention_days: int | None = Field(None, ge=1, le=365, description="Days to retain logs in database")
|
||||
log_level: str | None = Field(
|
||||
None, description="Log level: DEBUG, INFO, WARNING, ERROR, CRITICAL"
|
||||
)
|
||||
log_file_max_size_mb: int | None = Field(
|
||||
None, ge=1, le=1000, description="Max log file size in MB"
|
||||
)
|
||||
log_file_backup_count: int | None = Field(
|
||||
None, ge=0, le=50, description="Number of backup files to keep"
|
||||
)
|
||||
db_log_retention_days: int | None = Field(
|
||||
None, ge=1, le=365, description="Days to retain logs in database"
|
||||
)
|
||||
|
||||
@field_validator("log_level")
|
||||
@classmethod
|
||||
|
||||
@@ -12,8 +12,7 @@ Covers:
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
# ============================================================================
|
||||
# Credentials Schemas
|
||||
@@ -28,9 +27,7 @@ class LetzshopCredentialsCreate(BaseModel):
|
||||
None,
|
||||
description="Custom API endpoint (defaults to https://letzshop.lu/graphql)",
|
||||
)
|
||||
auto_sync_enabled: bool = Field(
|
||||
False, description="Enable automatic order sync"
|
||||
)
|
||||
auto_sync_enabled: bool = Field(False, description="Enable automatic order sync")
|
||||
sync_interval_minutes: int = Field(
|
||||
15, ge=5, le=1440, description="Sync interval in minutes (5-1440)"
|
||||
)
|
||||
|
||||
@@ -73,7 +73,9 @@ class MarketplaceProductBase(BaseModel):
|
||||
|
||||
# Categories
|
||||
google_product_category: str | None = None
|
||||
product_type_raw: str | None = None # Original feed value (renamed from product_type)
|
||||
product_type_raw: str | None = (
|
||||
None # Original feed value (renamed from product_type)
|
||||
)
|
||||
category_path: str | None = None
|
||||
|
||||
# Custom labels
|
||||
@@ -95,7 +97,9 @@ class MarketplaceProductBase(BaseModel):
|
||||
source_url: str | None = None
|
||||
|
||||
# Product type classification
|
||||
product_type_enum: str | None = None # 'physical', 'digital', 'service', 'subscription'
|
||||
product_type_enum: str | None = (
|
||||
None # 'physical', 'digital', 'service', 'subscription'
|
||||
)
|
||||
is_digital: bool | None = None
|
||||
|
||||
# Digital product fields
|
||||
@@ -124,8 +128,6 @@ class MarketplaceProductUpdate(MarketplaceProductBase):
|
||||
All fields are optional - only provided fields will be updated.
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class MarketplaceProductResponse(BaseModel):
|
||||
"""Schema for marketplace product API response."""
|
||||
|
||||
@@ -14,7 +14,6 @@ from typing import Any
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# SHARED RESPONSE SCHEMAS
|
||||
# ============================================================================
|
||||
|
||||
@@ -14,7 +14,6 @@ from typing import Any
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# SHARED RESPONSE SCHEMAS
|
||||
# ============================================================================
|
||||
@@ -134,7 +133,9 @@ class TestNotificationRequest(BaseModel):
|
||||
|
||||
template_id: int | None = Field(None, description="Template to use")
|
||||
email: str | None = Field(None, description="Override recipient email")
|
||||
notification_type: str = Field(default="test", description="Type of notification to send")
|
||||
notification_type: str = Field(
|
||||
default="test", description="Type of notification to send"
|
||||
)
|
||||
|
||||
|
||||
# ============================================================================
|
||||
|
||||
@@ -15,7 +15,6 @@ from typing import Any
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# PAYMENT CONFIGURATION SCHEMAS
|
||||
# ============================================================================
|
||||
@@ -152,7 +151,9 @@ class PaymentBalanceResponse(BaseModel):
|
||||
class RefundRequest(BaseModel):
|
||||
"""Request model for processing a refund."""
|
||||
|
||||
amount: float | None = Field(None, gt=0, description="Partial refund amount, or None for full refund")
|
||||
amount: float | None = Field(
|
||||
None, gt=0, description="Partial refund amount, or None for full refund"
|
||||
)
|
||||
reason: str | None = Field(None, max_length=500)
|
||||
|
||||
|
||||
|
||||
@@ -43,7 +43,10 @@ class VendorCreate(BaseModel):
|
||||
..., description="Unique subdomain for the vendor", min_length=2, max_length=100
|
||||
)
|
||||
name: str = Field(
|
||||
..., description="Display name of the vendor/brand", min_length=2, max_length=255
|
||||
...,
|
||||
description="Display name of the vendor/brand",
|
||||
min_length=2,
|
||||
max_length=255,
|
||||
)
|
||||
description: str | None = Field(None, description="Vendor/brand description")
|
||||
|
||||
@@ -53,10 +56,16 @@ class VendorCreate(BaseModel):
|
||||
letzshop_csv_url_de: str | None = Field(None, description="German CSV URL")
|
||||
|
||||
# Contact Info (optional - if not provided, inherited from company)
|
||||
contact_email: str | None = Field(None, description="Override company contact email")
|
||||
contact_phone: str | None = Field(None, description="Override company contact phone")
|
||||
contact_email: str | None = Field(
|
||||
None, description="Override company contact email"
|
||||
)
|
||||
contact_phone: str | None = Field(
|
||||
None, description="Override company contact phone"
|
||||
)
|
||||
website: str | None = Field(None, description="Override company website")
|
||||
business_address: str | None = Field(None, description="Override company business address")
|
||||
business_address: str | None = Field(
|
||||
None, description="Override company business address"
|
||||
)
|
||||
tax_number: str | None = Field(None, description="Override company tax number")
|
||||
|
||||
# Language Settings
|
||||
@@ -113,10 +122,16 @@ class VendorUpdate(BaseModel):
|
||||
is_verified: bool | None = None
|
||||
|
||||
# Contact Info (set value to override, set to empty string to reset to inherit)
|
||||
contact_email: str | None = Field(None, description="Override company contact email")
|
||||
contact_phone: str | None = Field(None, description="Override company contact phone")
|
||||
contact_email: str | None = Field(
|
||||
None, description="Override company contact email"
|
||||
)
|
||||
contact_phone: str | None = Field(
|
||||
None, description="Override company contact phone"
|
||||
)
|
||||
website: str | None = Field(None, description="Override company website")
|
||||
business_address: str | None = Field(None, description="Override company business address")
|
||||
business_address: str | None = Field(
|
||||
None, description="Override company business address"
|
||||
)
|
||||
tax_number: str | None = Field(None, description="Override company tax number")
|
||||
|
||||
# Special flag to reset contact fields to inherit from company
|
||||
@@ -212,17 +227,33 @@ class VendorDetailResponse(VendorResponse):
|
||||
tax_number: str | None = Field(None, description="Effective tax number")
|
||||
|
||||
# Inheritance flags (True = value is inherited from company, not overridden)
|
||||
contact_email_inherited: bool = Field(False, description="True if contact_email is from company")
|
||||
contact_phone_inherited: bool = Field(False, description="True if contact_phone is from company")
|
||||
website_inherited: bool = Field(False, description="True if website is from company")
|
||||
business_address_inherited: bool = Field(False, description="True if business_address is from company")
|
||||
tax_number_inherited: bool = Field(False, description="True if tax_number is from company")
|
||||
contact_email_inherited: bool = Field(
|
||||
False, description="True if contact_email is from company"
|
||||
)
|
||||
contact_phone_inherited: bool = Field(
|
||||
False, description="True if contact_phone is from company"
|
||||
)
|
||||
website_inherited: bool = Field(
|
||||
False, description="True if website is from company"
|
||||
)
|
||||
business_address_inherited: bool = Field(
|
||||
False, description="True if business_address is from company"
|
||||
)
|
||||
tax_number_inherited: bool = Field(
|
||||
False, description="True if tax_number is from company"
|
||||
)
|
||||
|
||||
# Original company values (for reference in UI)
|
||||
company_contact_email: str | None = Field(None, description="Company's contact email")
|
||||
company_contact_phone: str | None = Field(None, description="Company's phone number")
|
||||
company_contact_email: str | None = Field(
|
||||
None, description="Company's contact email"
|
||||
)
|
||||
company_contact_phone: str | None = Field(
|
||||
None, description="Company's phone number"
|
||||
)
|
||||
company_website: str | None = Field(None, description="Company's website URL")
|
||||
company_business_address: str | None = Field(None, description="Company's business address")
|
||||
company_business_address: str | None = Field(
|
||||
None, description="Company's business address"
|
||||
)
|
||||
company_tax_number: str | None = Field(None, description="Company's tax number")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user