"""
Django settings for TheSafeDeal project.

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

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

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

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


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

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'gi99kb*cj!-low)ach4(o!%fv6oq-!616*8b*pt^eb-*j359un'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True


# Host of the website, we put the name of the host here 'DealWithIt.com' for exemple
ALLOWED_HOSTS = ["127.0.0.1","192.168.1.16","192.168.1.41"]


# Application definition (name of the application is TheSafeDeal_NoAdmin)

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'TheSafeDeal_NoAdmin',
    'corsheaders',
]

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

# CORS_ORIGIN_WHITELIST = (
#     'localhost:8100',
#     '127.0.0.1'
# )

ROOT_URLCONF = 'TheSafeDeal.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        '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 = 'TheSafeDeal.wsgi.application'


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

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}


# Password validation
# https://docs.djangoproject.com/en/1.11/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/1.11/topics/i18n/

LANGUAGE_CODE = 'fr'

# Timezone de Paris pour la date des projets ainsi que du contrat (doit être changé dans le cas d'un serveur hors France ou site internationnal.)

TIME_ZONE = 'Europe/Paris'

USE_I18N = True

USE_L10N = True

USE_TZ = True


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

# Root of the project for static files (js, css, img ...)

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

# Modifiez email pour le serveur SMTP. Le serveur active directement le compte pour le moment.
# Système de validation du profil inactif.

EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.live.com'
EMAIL_HOST_USER = 'tim.montety@live.fr'
EMAIL_HOST_PASSWORD = ''
DEFAULT_FROM_EMAIL = 'tim.montety@live.fr'
EMAIL_PORT = 25
# URL pour la redirection après le login
LOGIN_REDIRECT_URL = 'connected'
# Custom model pour login/register
AUTH_USER_MODEL = 'TheSafeDeal_NoAdmin.CustomUser'

#URL/ROOT pour les fichiers.
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

"""
Pour mettre en place le serveur sous https, il faut d'abord créer un certificat, activer le https hors django puis enfin décomenter les 3 lignes ci dessous.
"""
#SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
#CSRF_COOKIE_SECURE = True
#SESSION_COOKIE_SECURE = True

CORS_ORIGIN_ALLOW_ALL = True