"""
Django settings for mail_server project.

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

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

For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.0/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/2.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '15lb$*d+mfbb+c+wzdf-9z*^^j-01zeo=^3vse(1&ih&9mc)g9'

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

ADMINS = [('Martin Stevko', 'mstevko10@gmail.com')]
MANAGERS = ADMINS

ALLOWED_HOSTS = ['slu.pythonanywhere.com', 'localhost']

APPEND_SLASH = True

# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'tinymce',
    'mailing',
]

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

ROOT_URLCONF = 'mail_server.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            os.path.join(BASE_DIR, '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 = 'mail_server.wsgi.application'


# Database
# https://docs.djangoproject.com/en/2.0/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/2.0/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.0/topics/i18n/

LANGUAGE_CODE = 'Sk-sk'

TIME_ZONE = 'Europe/Bratislava'

USE_I18N = True

USE_L10N = True

USE_TZ = True


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

'''
### Deployment ### + set DEBUG = False
STATIC_ROOT = '/var/www/mailing.pythonanywhere.com/static/'
# for collectstatic command - '/home/mailing/mailing/static/'

MEDIA_ROOT  = '/var/www/mailing.pythonanywhere.com/media/'
##################
'''

# Development #
STATIC_ROOT = os.path.dirname(os.path.abspath(__file__))

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

STATIC_URL = '/static/'

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
    #'/var/www/static/',
)

MEDIA_URL = '/media/'

# AUTH_USER_MODEL = 'users.User'

LOGIN_URL = 'admin:login'
# EMAIL_LOGIN_URL = '/ucet/prihlasenie_emailom/'
LOGOUT_URL = 'admin:logout'

UPLOAD_FILE_MAX_SIZE = 2 * 1024 * 1024 # 2MB

TINYMCE_DEFAULT_CONFIG = {
    'selector': 'textarea',
    'theme': 'modern',
    'plugins': 'link image preview codesample contextmenu table code lists '
               'charmap visualchars fullscreen textcolor colorpicker emoticons hr wordcount',
    'toolbar1':
        'fullscreen | styleselect formatselect | bold italic underline strikethrough subscript superscript removeformat |'
        ' forecolor backcolor | alignleft aligncenter alignright alignjustify |'
        ' bullist numlist | outdent indent | table | link image | emoticons charmap hr visualchars | preview code',
    'content_css': STATIC_URL+'css/bootstrap.css',
    'contextmenu': 'copy paste cut | formats removeformat | link image | table',
    'menubar': False,
    'inline': False,
    'statusbar': True,
    'branding': False,
    'width': 'auto',
    'max-width': '100vw',
    'height': 360,
    'plugin_preview_width': '350',
    'plugin_preview_height': '350',
    'code_dialog_width': '350',
    'code_dialog_height': '350'
}


# Mail configuration

# Enable Captcha on gmail account

EMAIL_HOST = 'smtp.gmail.com'

EMAIL_HOST_USER = 'riesky.web.testing@gmail.com'
EMAIL_HOST_PASSWORD = '' # heslo na riesky testy

EMAIL_PORT = 587
EMAIL_USE_TLS = True
