"""
Django settings for PMO project.

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

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
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


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

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '+u$uml075pj$%whboasa%%!=(b!mb!se_ed&*3q&@&u=*-4o9x'

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


# Application definition

INSTALLED_APPS = [
    'registration',#aqui se añade la app, y despues ir abajo completamente a auth redirects
    'admin_interface',
    'colorfield',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'ckeditor', #es necesario instalarlo pip install django-ckeditor para el editor de texto amplio, luego en los modelos que queramos importarlo se debe hacer asi from ckeditor.fields import RichTextField y sustituiremos los cmpos models.textfield por RichTextField
    'contact',
    'core',
    'messenger',
    'pages.apps.PagesConfig',
    'portfolio.apps.PortfolioConfig',
    'profiles',
    'documentos',
    'django_filters',
    'bootstrapform',
    
]
X_FRAME_OPTIONS='SAMEORIGIN'
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 = 'PMO.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', #maneja la autenticacion e inyecta datos de la sesion activa dentro de los templates,dirijirse a los templates
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'PMO.wsgi.application'


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

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}


# 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.1/topics/i18n/

LANGUAGE_CODE = 'es'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True




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

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

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

#Ckeditor
CKEDITOR_CONFIGS = {
    'default': {
        'toolbar': 'Custom',
        'toolbar_Custom': [
            ['Bold'],
            [ 'BulletedList',   'JustifyLeft', 'JustifyBlock'],
            
        ],
        'height': 80,
        'width': 1100,
    }
}
#para errores visitar:
#https://stackoverflow.com/questions/26697565/django-smtpauthenticationerror
#https://support.google.com/mail/answer/7126229?visit_id=637664577701779041-1946219617&rd=2#cantsignin&zippy=%2Cno-puedo-acceder-a-mi-cliente-de-correo-electr%C3%B3nico
#Email config 
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER='oficinadeproyectos2021@gmail.com'
EMAIL_HOST_PASSWORD='oficinadeproyectos123abc'
EMAIL_PORT='587'
EMAIL_USE_TLS=True

#Auth redirects
LOGIN_REDIRECT_URL= 'projects:projects'
LOGOUT_REDIRECT_URL= 'login'

#emails
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' #restablecer contraseña