from .base import *
import ssl

# macOS dev fix: skip SSL cert verification for SMTP (cPanel server)
_orig_ssl_ctx = ssl.create_default_context
def _dev_ssl_ctx(*args, **kwargs):
    ctx = _orig_ssl_ctx(*args, **kwargs)
    ctx.check_hostname = False
    ctx.verify_mode = ssl.CERT_NONE
    return ctx
ssl.create_default_context = _dev_ssl_ctx

DEBUG = True
ALLOWED_HOSTS = ['localhost', '127.0.0.1', '0.0.0.0']
SITE_URL = 'http://localhost:8000'

# No SQLite fallback. There used to be one, and on 3 August a folder copy
# left three identical db.sqlite3 snapshots on the Mac, each holding every
# credential, decryptable with the FIELD_ENCRYPTION_KEY that sat in the same
# folder. A default that quietly creates a database is how that happened.
# Development points at PostgreSQL like everything else, or it does not run.
DATABASES = {
    'default': env.db('DATABASE_URL')
}

# Disable WhiteNoise compression in dev
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage'

# Email backend is read from .env (SMTP when configured, console as fallback)

# Disable Redis in dev - use dummy cache
CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
    }
}
SESSION_ENGINE = 'django.contrib.sessions.backends.db'
