"""
Django settings for gazeanalyser project.

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

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

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

import os, re



# 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.9/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'zp_^e(2j8k(_m1@t(99*-#(opk*$ojz$8t04=bum1y&m9clh6t'

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

ALLOWED_HOSTS = ['visagetechnologies.com', 'www.visagetechnologies.com', '94.254.0.174', 'gea-analysis.com', 'www.gea-analysis.com']


# Application definition

INSTALLED_APPS = [
	'gazeanalyserapp.apps.GazeanalyserappConfig',
	'emodb.apps.EmodbConfig',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
	'maintenancemode',
]

MIDDLEWARE_CLASSES = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
	'maintenancemode.middleware.MaintenanceModeMiddleware',
]

ROOT_URLCONF = 'gazeanalyser.urls'

MAINTENANCE_MODE = False

MAINTENANCE_IGNORE_URLS = (
    re.compile(r'^/admin.*'),
)

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',
				'django.core.context_processors.media',
				'django.core.context_processors.static',
            ],
        },
    },
]

WSGI_APPLICATION = 'gazeanalyser.wsgi.application'


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

#DB ON VISAGE_DB_SERVER

DATABASES = {
	'default': {
		'ENGINE': 'django.db.backends.mysql', 
		'NAME': 'u4020561_g',
		'USER': 'geadb',
		'PASSWORD': 'g34@v154g3g34vp5',
		'HOST': '127.0.0.1',   # Or an IP Address that your DB is hosted on
		'PORT': '3306',
		'OPTIONS': {
			'read_default_file': 'config.cnf',
		},
	}
}

MEDIA_URL = '/gea-beta/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
	
# Password validation
# https://docs.djangoproject.com/en/1.9/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.9/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'Europe/Zagreb'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.9/howto/static-files/
STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), )
STATIC_ROOT ='/static/'
LOGIN_URL = 'login'
STATIC_URL = '/gea-beta/static/'

SECURE_SSL_REDIRECT = True
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
	
LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'verbose': {
            'format' : "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s",
            'datefmt' : "%d/%b/%Y %H:%M:%S"
        },
        'simple': {
            'format': '%(levelname)s %(message)s'
        },
    },
    'handlers': {
        'file': {
            'level': 'DEBUG',
            'class': 'logging.FileHandler',
            'filename': 'gea-beta.log',
            'formatter': 'verbose'
        },
    },
    'loggers': {
        'django': {
            'handlers':['file'],
            'propagate': True,
            'level':'DEBUG',
        },
        'gazeanalyserapp': {
            'handlers': ['file'],
            'level': 'DEBUG',
        },
    }
}

EMAIL_HOST='smtp.fsdata.se'
EMAIL_PORT='25'
EMAIL_HOST_USER='gea@visagetechnologies.com'
EMAIL_HOST_PASSWORD='Dx=T(LSzysgb'
EMAIL_SUBJECT_PREFIX='[GEA]'
EMAIL_USE_TLS=True