# -*- coding: utf-8 -*-

from django.utils.translation import ugettext_lazy as _
import cloudinary

"""
Django settings for idetra project.
Generated by 'django-admin startproject' using Django 1.8.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/

*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
TO DO!!!!

BEFORE MIGRATE:
-watch out for hidden files and the .htaccess files
under idetra and static_in_env > media_root
-SYMLINKS ARE NEVER ON THE COMPUTER,
so migrate folder by folder from idetra onwards

AFTER MIGRATE:
check all libs (pip install -r requirements.txt)
DEBUG = False
ALLOWED_HOSTS = ['idetra.org','www.idetra.org']
STATIC_ROOT = '/home3/matanayc/public_html/static_in_env/static_root/'
MEDIA_ROOT = '/home3/matanayc/public_html/static_in_env/media_root/'
SECURE_SSL_REDIRECT = True
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
/admin (for redux reg) - domain name and display name = www.idetra.org

SSH:
python manage.py
- makemigrations
- migrate
- collectstatic
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
makemessages -l pt_BR
compilemessages

BLUEHOST:
So ADMIN STATIC works:
ln -s $HOME/python27/lib/python2.7/site-packages/django/contrib/admin/static $HOME/public_html/idetra/static
So STATIC static works:
ln -s $HOME/public_html/static_in_env/static_root/ $HOME/public_html/idetra/static
So MEDIA works:
ln -s $HOME/public_html/static_in_env/media_root/ $HOME/public_html/idetra/media
create .htaccess inside MEDIA_ROOT file (the outside project folder)
place "Options -Indexes" there (without quotes)

dont forget .htacces from project and .htaccess from projectfile (inside project folder)

"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

LANGUAGES = (
    ('en', _('English')),
    ('pt-br', _('Portugues')),
)

#LANGUAGE_COOKIE_NAME

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

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'm^!nv))$#)b3#3kn61xx+-g()s!x7tggw#&-=peo5al&^ter@r'

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

ALLOWED_HOSTS = ['*']
#ALLOWED_HOSTS = ['idetra.org','www.idetra.org']

# INTERNAL_IPS = (
#     '127.0.0.1',
# )

# EMAIL SMTP TAGS DEFINITIONS
EMAIL_HOST = 'box6512.bluehost.com'
EMAIL_HOST_USER = 'idetra@idetra.org'
EMAIL_HOST_PASSWORD = 'none'
EMAIL_PORT = 465
# EMAIL_USE_TLS = False
EMAIL_USE_SSL = True
DEFAULT_FROM_EMAIL = 'idetra@idetra.org'

INSTALLED_APPS = (
    #django apps
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.messages',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.staticfiles',
    #third party apps
    'cloudinary',
    'crispy_forms',
    'django_extensions',
    'registration',
    'fluent_comments',
    'threadedcomments',
    'django_comments',
    #project apps
    'website',
    'ci',
    'edu',
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    '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',
    'django.middleware.security.SecurityMiddleware',
)

ROOT_URLCONF = 'idetra.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',
                'django.template.context_processors.media',
            ],
        },
    },
]

WSGI_APPLICATION = 'idetra.wsgi.application'

# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

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

STATIC_URL = '/static/'

# LOCAL:
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static_in_env", "static_root")

# PRODUCTION:
#STATIC_ROOT = '/home3/matanayc/public_html/static_in_env/static_root/'

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

MEDIA_URL = '/media/'
#MEDIA_URL = 'https://idetra.org/media/' # not used

# LOCAL:
MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static_in_env", "media_root")

# PRODUCTION:
#MEDIA_ROOT = '/home3/matanayc/public_html/static_in_env/media_root/'

# PROTECTED_MEDIA
# not used

# - - - - - - - - - - DJANGO REGISTRATION REDUX TAG SETTINGS
# ACCOUNT_ACTIVATION_DAYS - Number of days users will have to activate their accounts after registering.
# If not activate within that period, account will remain permanently inactive and may be deleted by maintenance scripts provided in django-registration-redux.
ACCOUNT_ACTIVATION_DAYS = 10

# REGISTRATION_AUTO_LOGIN - Optional. If True, users will automatically log in when they click on the activation link in their email.
# Defaults to False.
REGISTRATION_AUTO_LOGIN = True

# REGISTRATION_EMAIL_HTML - Optional. If this is False, registration emails will be send in plain text.
# If this is True, emails will be sent as HTML.
# Defaults to True.
REGISTRATION_EMAIL_HTML = True

#INCLUDE_REGISTER_URL = True

#INCLUDE_AUTH_URLS = True

# - - - - - - - - - - CRISPY FORMS TAGS SETTINGS
#CRISPY_TEMPLATE_PACK = 'uni_form' #check later if its better than bootstrap4
CRISPY_TEMPLATE_PACK = 'bootstrap4'

LOCALE_PATHS = (
    os.path.join(BASE_DIR, 'locale'),
    
    )

# Required for REGISTRATION REDUX rendering
SITE_ID = 1

# Where users should go when logged in (REDUX)
LOGIN_REDIRECT_URL = '/' # '/profile/'

# when a form is fully customized, call it here (below)
#REGISTRATION_FORM = 'website.forms.ExtraInForm'
#REGISTRATION_BACKEND_CLASS = 'website.regbackend.MyRegistrationBackend'

# - - - - - - - - - - CLOUDINARY SETTINGS
cloudinary.config(
  cloud_name='idetra',
  api_key='369284983726371',
  api_secret='Ftl0YC23bUqlo4ahS5sRZUROIog'
)

# - - - - - - - - - - THREADED COMMENTS SETTINGS
COMMENTS_APP = 'fluent_comments'
COMMENT_MAX_LENGTH = 500
USE_THREADEDCOMMENTS = True
# COMMENTS_ALLOW_PROFANITIES # = True (defaults False)
# PROFANITIES_LIST # = ('fuck','shit', 'etc.') required if True on ALLOW_PROFANITIES

# - - - - - - - - - - SECURITY:
#SECURE_SSL_REDIRECT = True
#SESSION_COOKIE_SECURE = True
#CSRF_COOKIE_SECURE = True 








