45 lines
1.2 KiB
Python
45 lines
1.2 KiB
Python
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
from typing import Optional, List
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
model_config = SettingsConfigDict(
|
|
env_file=".env", env_file_encoding="utf-8", case_sensitive=False, extra="ignore"
|
|
)
|
|
|
|
SAGE_TYPE_DEVIS: int = 0
|
|
SAGE_TYPE_BON_COMMANDE: int = 10
|
|
SAGE_TYPE_PREPARATION: int = 20
|
|
SAGE_TYPE_BON_LIVRAISON: int = 30
|
|
SAGE_TYPE_BON_RETOUR: int = 40
|
|
SAGE_TYPE_BON_AVOIR: int = 50
|
|
SAGE_TYPE_FACTURE: int = 60
|
|
|
|
chemin_base: str
|
|
utilisateur: str = "Administrateur"
|
|
mot_de_passe: str
|
|
|
|
sage_gateway_token: str
|
|
|
|
smtp_host: Optional[str] = None
|
|
smtp_port: int = 587
|
|
smtp_user: Optional[str] = None
|
|
smtp_password: Optional[str] = None
|
|
smtp_from: Optional[str] = None
|
|
|
|
api_host: str = "0.0.0.0"
|
|
api_port: int = 8000
|
|
|
|
cors_origins: List[str] = ["*"]
|
|
|
|
|
|
settings = Settings()
|
|
|
|
|
|
def validate_settings():
|
|
"""Validation au démarrage"""
|
|
if not settings.chemin_base or not settings.mot_de_passe:
|
|
raise ValueError(" CHEMIN_BASE et MOT_DE_PASSE requis dans .env")
|
|
if not settings.sage_gateway_token:
|
|
raise ValueError(" SAGE_GATEWAY_TOKEN requis (doit être identique sur Linux)")
|
|
return True
|