from .base import *
import os

# Development settings
DEBUG = True

ALLOWED_HOSTS = os.getenv('ALLOWED_HOSTS', '*').split(',')

# SQLite by default for dev
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / os.getenv('SQLITE_NAME', 'db_local.sqlite3'),
    }
}

# Email: use SMTP if credentials provided, otherwise console
if os.getenv('EMAIL_HOST_USER'):
    EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
else:
    EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

# Celery local fallback: execute tasks inline without Redis/worker.
CELERY_TASK_ALWAYS_EAGER = True
CELERY_TASK_EAGER_PROPAGATES = True
CELERY_BROKER_URL = os.getenv('CELERY_BROKER_URL', 'memory://')

# During local development allow the frontend to access the API.
# This makes cross-origin requests from e.g. http://localhost:5173 work.
CORS_ALLOW_ALL_ORIGINS = True
CORS_ALLOW_CREDENTIALS = True
