from .base import *
import os
from django.contrib.auth import get_user_model

SECRET_KEY = os.getenv("DJANGO_SECRET_KEY")

DEBUG = False

ALLOWED_HOSTS = os.getenv(
    "DJANGO_ALLOWED_HOSTS",
    "localhost"
).split(",")




DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.mysql",
        "NAME": os.getenv("DB_NAME"),
        "USER": os.getenv("DB_USER"),
        "PASSWORD": os.getenv("DB_PASSWORD"),
        "HOST": os.getenv("DB_HOST", "localhost"),
        "PORT": os.getenv("DB_PORT", "3306"),
        "OPTIONS": {
            "charset": "utf8mb4",
        },
    }
}



"""# Create Super user if it doesnt exist
def create_superuser_if_not_exists():
    User = get_user_model()

    if not User.objects.filter(is_superuser=True).exists():
        User.objects.create_superuser(
            username=os.environ["DJANGO_SUPERUSER_USERNAME"],
            email=os.environ["DJANGO_SUPERUSER_EMAIL"],
            password=os.environ["DJANGO_SUPERUSER_PASSWORD"],
        )"""


SECURE_SSL_REDIRECT = True
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True

SECURE_BROWSER_XSS_FILTER = True
X_FRAME_OPTIONS = 'DENY'

SECURE_CONTENT_TYPE_NOSNIFF = True

SECURE_REFERRER_POLICY = "same-origin"

SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")

STATIC_ROOT = BASE_DIR / 'staticfiles'


CORS_ALLOW_ALL_ORIGINS = True
CORS_ALLOWED_ORIGINS = []

CSRF_TRUSTED_ORIGINS = os.getenv(
    "DJANGO_CSRF_TRUSTED_ORIGINS",
    ""
).split(",")

STATICFILES_STORAGE = (
    "whitenoise.storage.CompressedManifestStaticFilesStorage"
)

USE_X_FORWARDED_HOST = True
"""
export DJANGO_SETTINGS_MODULE=config.settings.prod
python manage.py runserver
"""
