"""
Django settings for maralonga_project project.

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

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

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

import os
from datetime import datetime

# PHPHIL: internationalization
from django.utils.translation import gettext_lazy as _

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

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '*sw0n!4)i=+5#bb0bb=_#l@4x-5^ceow(=tih2y3)s@im^6#u9'

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

ALLOWED_HOSTS = ['localhost', '127.0.0.1', 'psytec.dns.army', 'www.psytec.dns.army', 'psytec.duckdns.org', 'www.psytec.duckdns.org', ]

# Application definition

INSTALLED_APPS = [
    'sendemail.apps.SendemailConfig',
    'psytec.apps.PsytecConfig',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'captcha',
]

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

ROOT_URLCONF = 'psytec_project.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')], # new
        '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',
                'psytec.context_processors.static_version',
            ],
        },
    },
]

WSGI_APPLICATION = 'psytec_project.wsgi.application'


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

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

# DATABASES = {
#     'default': {
#         'ENGINE': 'django.db.backends.postgresql_psycopg2',
#         'NAME': 'maralonga',
#         'USER': 'postgres',
#         #'PASSWORD': '',
#         #'HOST': 'localhost',
#         #'PORT': '',
#     }
# }


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

# Provide a lists of languages which your site supports.
LANGUAGES = (
    ('it', 'Italian'),
    ('en', 'English (US)'),
)

LANGUAGE_CODE = 'it'

TIME_ZONE = 'Europe/Zurich'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Tell Django where the project's translation files should be.
LOCALE_PATHS = (
    os.path.join(BASE_DIR, 'locale'),
)


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

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


# In production we’ll use the email service SendGrid to actually send the emails but for
# testing purposes we can rely on Django’s console backend setting which outputs the
# email text to our command line console instead.
#EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' #Console output
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' #SMTP email output

# Sendgreed relay smtp host config
#EMAIL_HOST = 'smtp.sendgrid.net'
#EMAIL_HOST_USER = 'apikey'
#EMAIL_HOST_PASSWORD = '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'
#EMAIL_PORT = 587
#EMAIL_USE_TLS = True

# gmail relay smtp host config
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = 'info.maralonga@gmail.com'
EMAIL_HOST_PASSWORD = 'dkypytgsgltwubdl'

# Captcha config
#CAPTCHA_CHALLENGE_FUNCT = 'captcha.helpers.random_char_challenge'
#CAPTCHA_CHALLENGE_FUNCT = 'captcha.helpers.math_challenge'
#CAPTCHA_MATH_CHALLENGE_OPERATOR = 'x'
#CAPTCHA_CHALLENGE_FUNCT = 'captcha.helpers.word_challenge'
CAPTCHA_IMAGE_SIZE = (73,28)
CAPTCHA_LETTER_ROTATION = (-10,10)
CAPTCHA_NOISE_FUNCTIONS = ('captcha.helpers.noise_arcs', 'captcha.helpers.noise_dots',)
CAPTCHA_LENGTH = 3

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = 'media/'

STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage'

## EDITABLE VARIABLES START ##

# Cambia questo numero ad ogni deploy
STATIC_VERSION = '4'

ML_SUBSCRIPTIONS_ENABLED = False
MC_SUBSCRIPTIONS_ENABLED = False

# SSH Configuration
REMOTE_HOST = '145.223.85.106'
REMOTE_USER = 'minecraft-reader'
SSH_KEY_PATH = '/var/www/.ssh/mc_reader'

MC_LOG_PASSWORD = "jolla"

ALLOWED_MC_SERVERS = {
    "S2":     {"address": "145.223.85.106:19132", "label": "Server Stagione 2"},
    # "S3":     {"address": "145.223.85.106:8888",  "label": "Server Stagione 3"},
    "Eventi": {"address": "145.223.85.106:19134", "label": "Server Eventi"},
}
## EDITABLE VARIABLES STOP ##
