Files
quality_app-v2/app/config.py
Quality App Developer d5b043c762 Fix Docker build and add labels test data
- Fix Docker build issues:
  * Add missing system dependencies (build-essential, python3-dev, libpq-dev)
  * Fix requirements.txt formatting (separate Flask-Session and openpyxl)
  * Update openpyxl version to 3.1.5 (3.10.0 was invalid)
- Set proper folder permissions for Docker write access (app/ and data/)
- Add comprehensive test data for labels module:
  * 8 sample orders (TEST-ORD-001 through TEST-ORD-008)
  * Mix of printed/unprinted orders for testing
  * Various product types, customers, and delivery dates
  * Ready for QZ Tray printing functionality testing
- Include test data generation scripts for future use
- Application now fully containerized and ready for labels/printing testing
2026-02-15 12:05:20 +02:00

83 lines
2.0 KiB
Python
Executable File

"""
Application Configuration
"""
import os
from datetime import timedelta
from dotenv import load_dotenv
# Load environment variables from .env file
load_dotenv()
class Config:
"""Base configuration"""
# Flask
SECRET_KEY = os.getenv('SECRET_KEY', 'dev-secret-key-change-in-production')
DEBUG = False
TESTING = False
# Session
PERMANENT_SESSION_LIFETIME = timedelta(hours=8)
SESSION_COOKIE_SECURE = False
SESSION_COOKIE_HTTPONLY = True
SESSION_COOKIE_SAMESITE = 'Lax'
# Database
DB_HOST = os.getenv('DB_HOST', 'localhost')
DB_PORT = int(os.getenv('DB_PORT', 3306))
DB_USER = os.getenv('DB_USER', 'quality_user')
DB_PASSWORD = os.getenv('DB_PASSWORD', 'password')
DB_NAME = os.getenv('DB_NAME', 'quality_db')
# Database pool settings
DB_POOL_SIZE = 10
DB_POOL_TIMEOUT = 30
DB_POOL_RECYCLE = 3600
# Application
APP_PORT = int(os.getenv('APP_PORT', 8080))
APP_HOST = os.getenv('APP_HOST', '0.0.0.0')
# Logging
LOG_LEVEL = os.getenv('LOG_LEVEL', 'INFO')
LOG_DIR = os.getenv('LOG_DIR', './data/logs')
# Upload settings
MAX_CONTENT_LENGTH = 100 * 1024 * 1024 # 100MB max upload
UPLOAD_FOLDER = os.getenv('UPLOAD_FOLDER', './data/uploads')
# Ensure directories exist
os.makedirs(LOG_DIR, exist_ok=True)
os.makedirs(UPLOAD_FOLDER, exist_ok=True)
class DevelopmentConfig(Config):
"""Development configuration"""
DEBUG = True
TESTING = False
class ProductionConfig(Config):
"""Production configuration"""
DEBUG = False
TESTING = False
SESSION_COOKIE_SECURE = True
class TestingConfig(Config):
"""Testing configuration"""
DEBUG = True
TESTING = True
DB_NAME = 'quality_db_test'
# Select configuration based on environment
env = os.getenv('FLASK_ENV', 'production')
if env == 'development':
ConfigClass = DevelopmentConfig
elif env == 'testing':
ConfigClass = TestingConfig
else:
ConfigClass = ProductionConfig