<reponame>mazi76erX2/football_forecaster
"""
Django settings for Football Forecaster project.

Generated by 'django-admin startproject' using Django 3.1.

For more information on this file, see
https://docs.djangoproject.com/en/3.1/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.1/ref/settings/
"""

from pathlib import Path
import os
from datetime import timedelta

from django.contrib.messages import constants as messages

from dotenv import load_dotenv
from cloudinary import config

load_dotenv()

MODE = (os.getenv('MODE') == 'production')

# Custom user model
# AUTH_USER_MODEL = "accounts.CustomUser"

ALLOWED_HOSTS = ['*']

DB_HOST = os.environ.get('DB_HOST')
DB_NAME = os.environ.get('DB_NAME')
DB_USER = os.environ.get('DB_USER')
DB_PASSWORD = os.environ.get('DB_PASSWORD')
DB_PORT = os.environ.get('DB_PORT')

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve(strict=True).parent.parent

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ.get('SECRET_KEY', default='fjm-%3(m78tv5^qe8sm_k)7@rzandileqx6!%067*&6gu8ph+x6unt740')

# Application definition

INSTALLED_APPS = [
    # admin menu
    'admin_menu',

    # default
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',

    # local-apps
    'accounts',
    'pages',

    # all-auth
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    'allauth.socialaccount.providers.facebook',
    'allauth.socialaccount.providers.google',
    'allauth.socialaccount.providers.twitter',

    # third-party
    'django_registration',
    'widget_tweaks',
    'corsheaders',
    'rest_framework',
    'rest_framework.authtoken',
    'django_better_admin_arrayfield',
    'django_filters',
    'cloudinary',
    'rest_registration',
    'letsencrypt',
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'corsheaders.middleware.CorsMiddleware',
    'whitenoise.middleware.WhiteNoiseMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'football_forecaster.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR.parent, 'templates'), ],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'football_forecaster.wsgi.application'

"""""""""""""""""""""""""""""""""""""""""""""""""""""
# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
"""""""""""""""""""""""""""""""""""""""""""""""""""""

if os.getenv('TEST'):
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': os.path.join(BASE_DIR.parent, 'db.sqlite3'),
        }
    }
else:
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.postgresql',
            'NAME': DB_NAME,
            'USER': DB_USER,
            'PASSWORD': DB_PASSWORD,
            'HOST': DB_HOST,
            'PORT': DB_PORT,
        }
    }

# Password validation
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]

# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/

LANGUAGE_CODE = 'en'

TIME_ZONE = 'Africa/Johannesburg'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static_root")

MEDIA_URL = "/media/"
MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "media_root")
SITE_ID = 1

STATICFILES_DIRS = [
    BASE_DIR.parent / "static",
    # os.path.join(BASE_DIR, 'assets'),
]

LOGIN_URL = "/login/"
LOGIN_REDIRECT_URL = "/logged_in/"
LOGOUT_REDIRECT_URL = "/"

"""""""""""""""""""""""""""""""""""""""""""""""""""""
                Site Settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""

SITE_NAME = os.getenv('SITE_NAME')

"""""""""""""""""""""""""""""""""""""""""""""""""""""
                Admin Menu Settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""

ADMIN_LOGO = 'img/logo.png'

# MENU_WEIGHT = {
#     'World': 20,
#     'Auth': 4,
#     'Sample': 5
# }

ADMIN_STYLE = {
    'primary-color': '#B42D33',
    'secondary-color': '#000000',
    'tertiary-color': '#333333'
}

"""""""""""""""""""""""""""""""""""""""""""""""""""""
                Message Settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""

MESSAGE_TAGS = {
    messages.DEBUG: 'debug',
    messages.INFO: 'info',
    messages.SUCCESS: 'success',
    messages.WARNING: 'warning',
    messages.ERROR: 'danger',
}

"""""""""""""""""""""""""""""""""""""""""""""""""""""
            Authentication Settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""

AUTHENTICATION_BACKENDS = [
    # Needed to login by username in Django admin, regardless of `allauth`
    'django.contrib.auth.backends.ModelBackend',

    # `allauth` specific authentication methods, such as login by e-mail
    'allauth.account.auth_backends.AuthenticationBackend',
]

"""""""""""""""""""""""""""""""""""""""""""""""""""""
                All-Auth Settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""

# Provider specific settings
SOCIALACCOUNT_PROVIDERS = {
    'facebook': {
        'METHOD': 'oauth2',
        'SDK_URL': '//connect.facebook.net/{locale}/sdk.js',
        'SCOPE': ['email', 'public_profile'],
        'AUTH_PARAMS': {'auth_type': 'reauthenticate'},
        'INIT_PARAMS': {'cookie': True},
        'FIELDS': [
            'id',
            'email',
            'name',
            'first_name',
            'last_name',
            'verified',
            'locale',
            'timezone',
            'link',
            'gender',
            'updated_time',
        ],
        'EXCHANGE_TOKEN': True,
        'LOCALE_FUNC': 'path.to.callable',
        'VERIFIED_EMAIL': False,
        'VERSION': 'v7.0',
    },
    'google': {
        # For each OAuth based provider, either add a ``SocialApp``
        # (``socialaccount`` app) containing the required client
        # credentials, or list them here:
        'APP': {
            'client_id': os.getenv('GOOGLE_CLIENT_ID'),
            'secret': os.getenv('GOOGLE_SECRET_KEY'),
            'key': os.getenv('GOOGLE_API_KEY'),
        }
    },
    'twitter': {
        # For each OAuth based provider, either add a ``SocialApp``
        # (``socialaccount`` app) containing the required client
        # credentials, or list them here:
        'APP': {
            'client_id': os.getenv('TWITTER_CLIENT_ID'),
            'secret': os.getenv('TWITTER_SECRET_KEY'),
            'key': os.getenv('TWITTER_API_KEY'),
        }
    },
}

"""""""""""""""""""""""""""""""""""""""""""""""""""""
                    CDN
"""""""""""""""""""""""""""""""""""""""""""""""""""""
CDN_NAME = os.environ.get('CDN_NAME')
CDN_API_KEY = os.environ.get('CDN_API_KEY')
CDN_API_SECRET = os.environ.get('CDN_API_SECRET')

"""""""""""""""""""""""""""""""""""""""""""""""""""""
                Twilio Settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""

TWILIO_ACCOUNT_SID = os.environ.get('TWILIO_ACCOUNT_SID')
TWILIO_AUTH_TOKEN = os.environ.get('TWILIO_AUTH_TOKEN')
TWILIO_WPP_NUMBER = os.environ.get('TWILIO_WPP_NUMBER')

"""""""""""""""""""""""""""""""""""""""""""""""""""""
            Cloudinary Settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""
# Cloudinary
# https://cloudinary.com/documentation/django_integration

config(
    cloud_name=CDN_NAME,
    api_key=CDN_API_KEY,
    api_secret=CDN_API_SECRET,
    secure=True
)

# Email 
# https://docs.djangoproject.com/en/3.0/topics/email/

# Gmail SMTP requirements
# https://support.google.com/a/answer/176600?hl=en

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = os.getenv('EMAIL_HOST')
EMAIL_HOST_USER = os.getenv('EMAIL_HOST_USER')
EMAIL_HOST_PASSWORD = os.getenv('EMAIL_HOST_PASSWORD')
EMAIL_PORT = os.getenv('EMAIL_PORT')
EMAIL_USE_TLS = True
EMAIL_USE_SSL = False
DEFAULT_FROM_EMAIL = os.getenv('DEFAULT_FROM_EMAIL')

"""""""""""""""""""""""""""""""""""""""""""""""""""""
                Django Registration
"""""""""""""""""""""""""""""""""""""""""""""""""""""

ACCOUNT_ACTIVATION_DAYS = 7

"""""""""""""""""""""""""""""""""""""""""""""""""""""
                Django REST Registration
"""""""""""""""""""""""""""""""""""""""""""""""""""""

REST_REGISTRATION = {
    'REGISTER_VERIFICATION_ENABLED': False,
    'REGISTER_EMAIL_VERIFICATION_ENABLED': False,
    'RESET_PASSWORD_VERIFICATION_ENABLED': False,

    # 'REGISTER_VERIFICATION_URL': f'{os.getenv('REGISTER_VERIFICATION_URL')}/verify-user/',
    # 'RESET_PASSWORD_VERIFICATION_URL': f'{os.getenv('RESET_PASSWORD_VERIFICATION_URL')}/reset-password/',
    # 'REGISTER_EMAIL_VERIFICATION_URL': f'{os.getenv('REGISTER_EMAIL_VERIFICATION_URL')}/verify-email/',
    #
    # 'VERIFICATION_FROM_EMAIL': os.getenv('VERIFICATION_FROM_EMAIL') # '<EMAIL>',
}

"""""""""""""""""""""""""""""""""""""""""""""""""""""
                Region Settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""

LANGUAGES = (('en', 'English'),)
COUNTRIES = (('za', 'South Africa'),)
PROVINCES = (
    ('ec', 'Eastern Cape'),
    ('fs', 'Free State'),
    ('gau', 'Gauteng'),
    ('kzn', 'KwaZulu-Natal'),
    ('lim', 'Limpopo'),
    ('mpu', 'Mpumalanga'),
    ('nc', 'Northern Cape'),
    ('nw', 'North West'),
    ('wc', 'Western Cape'),
)

"""""""""""""""""""""""""""""""""""""""""""""""""""""
            Django REST Framework
"""""""""""""""""""""""""""""""""""""""""""""""""""""

# Django Rest Framework
# https://www.django-rest-framework.org/

REST_FRAMEWORK = {
    'DEFAULT_PERMISSION_CLASSES': (
        'rest_framework.permissions.IsAuthenticated',
        'rest_framework.authentication.SessionAuthentication',
    ),
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework.authentication.SessionAuthentication',
    ),
    'DEFAULT_FILTER_BACKENDS': (
        'django_filters.rest_framework.DjangoFilterBackend',
    ),
    'DEFAULT_RENDERER_CLASSES': (
        'rest_framework.renderers.JSONRenderer',
    ),
}

SIMPLE_JWT = {
    'ACCESS_TOKEN_LIFETIME': timedelta(minutes=5),
    'REFRESH_TOKEN_LIFETIME': timedelta(days=14),
    'ROTATE_REFRESH_TOKENS': True,
    'BLACKLIST_AFTER_ROTATION': False,
    'ALGORITHM': 'HS256',
    'SIGNING_KEY': os.environ.get('SECRET_KEY', default='fjm-%3(m78tv5^qe8sm_k)7@lash!%067*&6gu8ph+x6unt740'),
    'VERIFYING_KEY': None,
    'AUTH_HEADER_TYPES': ('JWT',),
    'USER_ID_FIELD': 'id',
    'USER_ID_CLAIM': 'user_id',
    'AUTH_TOKEN_CLASSES': ('rest_framework_simplejwt.tokens.AccessToken',),
    'TOKEN_TYPE_CLAIM': 'token_type',
}

"""""""""""""""""""""""""""""""""""""""""""""""""""""
                CSFR Settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""

CSRF_COOKIE_SAMESITE = 'Strict'
SESSION_COOKIE_SAMESITE = 'Strict'
CSRF_COOKIE_HTTPONLY = True
SESSION_COOKIE_HTTPONLY = True

"""""""""""""""""""""""""""""""""""""""""""""""""""""
                    CORS Headers
"""""""""""""""""""""""""""""""""""""""""""""""""""""

CORS_ORIGIN_WHITELIST = (
    'http://localhost:3000',
)

CORS_EXPOSE_HEADERS = ['Content-Type', 'X-CSRFToken']
CORS_ALLOW_CREDENTIALS = True
CORS_ORIGIN_ALLOW_ALL = True

"""""""""""""""""""""""""""""""""""""""""""""""""""""
                    Email Admins
"""""""""""""""""""""""""""""""""""""""""""""""""""""

ADMINS = [
    ('Xolani', '<EMAIL>'),
]

"""
Django settings for Football Forecaster project.

Generated by 'django-admin startproject' using Django 3.1.

For more information on this file, see
https://docs.djangoproject.com/en/3.1/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.1/ref/settings/
"""

from pathlib import Path
import os
from datetime import timedelta

from django.contrib.messages import constants as messages

from dotenv import load_dotenv
from cloudinary import config

load_dotenv()

MODE = (os.getenv('MODE') == 'production')

# Custom user model
# AUTH_USER_MODEL = "accounts.CustomUser"

ALLOWED_HOSTS = ['*']

DB_HOST = os.environ.get('DB_HOST')
DB_NAME = os.environ.get('DB_NAME')
DB_USER = os.environ.get('DB_USER')
DB_PASSWORD = os.environ.get('DB_PASSWORD')
DB_PORT = os.environ.get('DB_PORT')

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve(strict=True).parent.parent

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ.get('SECRET_KEY', default='fjm-%3(m78tv5^qe8sm_k)7@rzandileqx6!%067*&6gu8ph+x6unt740')

# Application definition

INSTALLED_APPS = [
    # admin menu
    'admin_menu',

    # default
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',

    # local-apps
    'accounts',
    'pages',

    # all-auth
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    'allauth.socialaccount.providers.facebook',
    'allauth.socialaccount.providers.google',
    'allauth.socialaccount.providers.twitter',

    # third-party
    'django_registration',
    'widget_tweaks',
    'corsheaders',
    'rest_framework',
    'rest_framework.authtoken',
    'django_better_admin_arrayfield',
    'django_filters',
    'cloudinary',
    'rest_registration',
    'letsencrypt',
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'corsheaders.middleware.CorsMiddleware',
    'whitenoise.middleware.WhiteNoiseMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'football_forecaster.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR.parent, 'templates'), ],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'football_forecaster.wsgi.application'

"""""""""""""""""""""""""""""""""""""""""""""""""""""
# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
"""""""""""""""""""""""""""""""""""""""""""""""""""""

if os.getenv('TEST'):
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': os.path.join(BASE_DIR.parent, 'db.sqlite3'),
        }
    }
else:
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.postgresql',
            'NAME': DB_NAME,
            'USER': DB_USER,
            'PASSWORD': DB_PASSWORD,
            'HOST': DB_HOST,
            'PORT': DB_PORT,
        }
    }

# Password validation
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]

# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/

LANGUAGE_CODE = 'en'

TIME_ZONE = 'Africa/Johannesburg'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static_root")

MEDIA_URL = "/media/"
MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "media_root")
SITE_ID = 1

STATICFILES_DIRS = [
    BASE_DIR.parent / "static",
    # os.path.join(BASE_DIR, 'assets'),
]

LOGIN_URL = "/login/"
LOGIN_REDIRECT_URL = "/logged_in/"
LOGOUT_REDIRECT_URL = "/"

"""""""""""""""""""""""""""""""""""""""""""""""""""""
                Site Settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""

SITE_NAME = os.getenv('SITE_NAME')

"""""""""""""""""""""""""""""""""""""""""""""""""""""
                Admin Menu Settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""

ADMIN_LOGO = 'img/logo.png'

# MENU_WEIGHT = {
#     'World': 20,
#     'Auth': 4,
#     'Sample': 5
# }

ADMIN_STYLE = {
    'primary-color': '#B42D33',
    'secondary-color': '#000000',
    'tertiary-color': '#333333'
}

"""""""""""""""""""""""""""""""""""""""""""""""""""""
                Message Settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""

MESSAGE_TAGS = {
    messages.DEBUG: 'debug',
    messages.INFO: 'info',
    messages.SUCCESS: 'success',
    messages.WARNING: 'warning',
    messages.ERROR: 'danger',
}

"""""""""""""""""""""""""""""""""""""""""""""""""""""
            Authentication Settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""

AUTHENTICATION_BACKENDS = [
    # Needed to login by username in Django admin, regardless of `allauth`
    'django.contrib.auth.backends.ModelBackend',

    # `allauth` specific authentication methods, such as login by e-mail
    'allauth.account.auth_backends.AuthenticationBackend',
]

"""""""""""""""""""""""""""""""""""""""""""""""""""""
                All-Auth Settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""

# Provider specific settings
SOCIALACCOUNT_PROVIDERS = {
    'facebook': {
        'METHOD': 'oauth2',
        'SDK_URL': '//connect.facebook.net/{locale}/sdk.js',
        'SCOPE': ['email', 'public_profile'],
        'AUTH_PARAMS': {'auth_type': 'reauthenticate'},
        'INIT_PARAMS': {'cookie': True},
        'FIELDS': [
            'id',
            'email',
            'name',
            'first_name',
            'last_name',
            'verified',
            'locale',
            'timezone',
            'link',
            'gender',
            'updated_time',
        ],
        'EXCHANGE_TOKEN': True,
        'LOCALE_FUNC': 'path.to.callable',
        'VERIFIED_EMAIL': False,
        'VERSION': 'v7.0',
    },
    'google': {
        # For each OAuth based provider, either add a ``SocialApp``
        # (``socialaccount`` app) containing the required client
        # credentials, or list them here:
        'APP': {
            'client_id': os.getenv('GOOGLE_CLIENT_ID'),
            'secret': os.getenv('GOOGLE_SECRET_KEY'),
            'key': os.getenv('GOOGLE_API_KEY'),
        }
    },
    'twitter': {
        # For each OAuth based provider, either add a ``SocialApp``
        # (``socialaccount`` app) containing the required client
        # credentials, or list them here:
        'APP': {
            'client_id': os.getenv('TWITTER_CLIENT_ID'),
            'secret': os.getenv('TWITTER_SECRET_KEY'),
            'key': os.getenv('TWITTER_API_KEY'),
        }
    },
}

"""""""""""""""""""""""""""""""""""""""""""""""""""""
                    CDN
"""""""""""""""""""""""""""""""""""""""""""""""""""""
CDN_NAME = os.environ.get('CDN_NAME')
CDN_API_KEY = os.environ.get('CDN_API_KEY')
CDN_API_SECRET = os.environ.get('CDN_API_SECRET')

"""""""""""""""""""""""""""""""""""""""""""""""""""""
                Twilio Settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""

TWILIO_ACCOUNT_SID = os.environ.get('TWILIO_ACCOUNT_SID')
TWILIO_AUTH_TOKEN = os.environ.get('TWILIO_AUTH_TOKEN')
TWILIO_WPP_NUMBER = os.environ.get('TWILIO_WPP_NUMBER')

"""""""""""""""""""""""""""""""""""""""""""""""""""""
            Cloudinary Settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""
# Cloudinary
# https://cloudinary.com/documentation/django_integration

config(
    cloud_name=CDN_NAME,
    api_key=CDN_API_KEY,
    api_secret=CDN_API_SECRET,
    secure=True
)

# Email 
# https://docs.djangoproject.com/en/3.0/topics/email/

# Gmail SMTP requirements
# https://support.google.com/a/answer/176600?hl=en

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = os.getenv('EMAIL_HOST')
EMAIL_HOST_USER = os.getenv('EMAIL_HOST_USER')
EMAIL_HOST_PASSWORD = os.getenv('EMAIL_HOST_PASSWORD')
EMAIL_PORT = os.getenv('EMAIL_PORT')
EMAIL_USE_TLS = True
EMAIL_USE_SSL = False
DEFAULT_FROM_EMAIL = os.getenv('DEFAULT_FROM_EMAIL')

"""""""""""""""""""""""""""""""""""""""""""""""""""""
                Django Registration
"""""""""""""""""""""""""""""""""""""""""""""""""""""

ACCOUNT_ACTIVATION_DAYS = 7

"""""""""""""""""""""""""""""""""""""""""""""""""""""
                Django REST Registration
"""""""""""""""""""""""""""""""""""""""""""""""""""""

REST_REGISTRATION = {
    'REGISTER_VERIFICATION_ENABLED': False,
    'REGISTER_EMAIL_VERIFICATION_ENABLED': False,
    'RESET_PASSWORD_VERIFICATION_ENABLED': False,

    # 'REGISTER_VERIFICATION_URL': f'{os.getenv('REGISTER_VERIFICATION_URL')}/verify-user/',
    # 'RESET_PASSWORD_VERIFICATION_URL': f'{os.getenv('RESET_PASSWORD_VERIFICATION_URL')}/reset-password/',
    # 'REGISTER_EMAIL_VERIFICATION_URL': f'{os.getenv('REGISTER_EMAIL_VERIFICATION_URL')}/verify-email/',
    #
    # 'VERIFICATION_FROM_EMAIL': os.getenv('VERIFICATION_FROM_EMAIL') # '<EMAIL>',
}

"""""""""""""""""""""""""""""""""""""""""""""""""""""
                Region Settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""

LANGUAGES = (('en', 'English'),)
COUNTRIES = (('za', 'South Africa'),)
PROVINCES = (
    ('ec', 'Eastern Cape'),
    ('fs', 'Free State'),
    ('gau', 'Gauteng'),
    ('kzn', 'KwaZulu-Natal'),
    ('lim', 'Limpopo'),
    ('mpu', 'Mpumalanga'),
    ('nc', 'Northern Cape'),
    ('nw', 'North West'),
    ('wc', 'Western Cape'),
)

"""""""""""""""""""""""""""""""""""""""""""""""""""""
            Django REST Framework
"""""""""""""""""""""""""""""""""""""""""""""""""""""

# Django Rest Framework
# https://www.django-rest-framework.org/

REST_FRAMEWORK = {
    'DEFAULT_PERMISSION_CLASSES': (
        'rest_framework.permissions.IsAuthenticated',
        'rest_framework.authentication.SessionAuthentication',
    ),
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework.authentication.SessionAuthentication',
    ),
    'DEFAULT_FILTER_BACKENDS': (
        'django_filters.rest_framework.DjangoFilterBackend',
    ),
    'DEFAULT_RENDERER_CLASSES': (
        'rest_framework.renderers.JSONRenderer',
    ),
}

SIMPLE_JWT = {
    'ACCESS_TOKEN_LIFETIME': timedelta(minutes=5),
    'REFRESH_TOKEN_LIFETIME': timedelta(days=14),
    'ROTATE_REFRESH_TOKENS': True,
    'BLACKLIST_AFTER_ROTATION': False,
    'ALGORITHM': 'HS256',
    'SIGNING_KEY': os.environ.get('SECRET_KEY', default='fjm-%3(m78tv5^qe8sm_k)7@lash!%067*&6gu8ph+x6unt740'),
    'VERIFYING_KEY': None,
    'AUTH_HEADER_TYPES': ('JWT',),
    'USER_ID_FIELD': 'id',
    'USER_ID_CLAIM': 'user_id',
    'AUTH_TOKEN_CLASSES': ('rest_framework_simplejwt.tokens.AccessToken',),
    'TOKEN_TYPE_CLAIM': 'token_type',
}

"""""""""""""""""""""""""""""""""""""""""""""""""""""
                CSFR Settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""

CSRF_COOKIE_SAMESITE = 'Strict'
SESSION_COOKIE_SAMESITE = 'Strict'
CSRF_COOKIE_HTTPONLY = True
SESSION_COOKIE_HTTPONLY = True

"""""""""""""""""""""""""""""""""""""""""""""""""""""
                    CORS Headers
"""""""""""""""""""""""""""""""""""""""""""""""""""""

CORS_ORIGIN_WHITELIST = (
    'http://localhost:3000',
)

CORS_EXPOSE_HEADERS = ['Content-Type', 'X-CSRFToken']
CORS_ALLOW_CREDENTIALS = True
CORS_ORIGIN_ALLOW_ALL = True

"""""""""""""""""""""""""""""""""""""""""""""""""""""
                    Email Admins
"""""""""""""""""""""""""""""""""""""""""""""""""""""

ADMINS = [
    ('Xolani', '<EMAIL>'),
]
Django settings for Football Forecaster project.  Generated by 'django-admin startproject' using Django 3.1.  For more information on this file, see https://docs.djangoproject.com/en/3.1/topics/settings/  For the full list of settings and their values, see https://docs.djangoproject.com/en/3.1/ref/settings/ # Custom user model # AUTH_USER_MODEL = "accounts.CustomUser" # Build paths inside the project like this: BASE_DIR / 'subdir'. # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! # Application definition # admin menu # default # local-apps # all-auth # third-party "" # Database # https://docs.djangoproject.com/en/3.0/ref/settings/#databases # Password validation # https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators # Internationalization # https://docs.djangoproject.com/en/3.0/topics/i18n/ # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/3.0/howto/static-files/ # os.path.join(BASE_DIR, 'assets'), ""                 Site Settings ""                 Admin Menu Settings # MENU_WEIGHT = { #     'World': 20, #     'Auth': 4, #     'Sample': 5 # } ""                 Message Settings ""             Authentication Settings # Needed to login by username in Django admin, regardless of `allauth` # `allauth` specific authentication methods, such as login by e-mail ""                 All-Auth Settings # Provider specific settings # For each OAuth based provider, either add a ``SocialApp`` # (``socialaccount`` app) containing the required client # credentials, or list them here: # For each OAuth based provider, either add a ``SocialApp`` # (``socialaccount`` app) containing the required client # credentials, or list them here: ""                     CDN ""                 Twilio Settings ""             Cloudinary Settings # Cloudinary # https://cloudinary.com/documentation/django_integration # Email # https://docs.djangoproject.com/en/3.0/topics/email/ # Gmail SMTP requirements # https://support.google.com/a/answer/176600?hl=en ""                 Django Registration ""                 Django REST Registration # 'REGISTER_VERIFICATION_URL': f'{os.getenv('REGISTER_VERIFICATION_URL')}/verify-user/', # 'RESET_PASSWORD_VERIFICATION_URL': f'{os.getenv('RESET_PASSWORD_VERIFICATION_URL')}/reset-password/', # 'REGISTER_EMAIL_VERIFICATION_URL': f'{os.getenv('REGISTER_EMAIL_VERIFICATION_URL')}/verify-email/', # # 'VERIFICATION_FROM_EMAIL': os.getenv('VERIFICATION_FROM_EMAIL') # '<EMAIL>', ""                 Region Settings ""             Django REST Framework # Django Rest Framework # https://www.django-rest-framework.org/ ""                 CSFR Settings ""                     CORS Headers ""                     Email Admins