"""
Django settings for project project.

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

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

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

import os
import dj_database_url


# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))


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

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = str(os.environ.get('DJANGO_SECRET'))

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

ALLOWED_HOSTS = ['*']


# Application definition

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

    'custom_auth',
    'main',
    'spotteds',
    'moderation',
    'api',

    'captcha',
]

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.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'project.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',
                'django.contrib.messages.context_processors.messages',
                'main.context_processors.enable_mod_shift',
                'main.context_processors.enable_imgur_upload',
                'main.context_processors.enable_ad_tag',
                'main.context_processors.ad_slot'
            ],
        },
    },
]

WSGI_APPLICATION = 'project.wsgi.application'


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

LANGUAGE_CODE = 'pt-br'

TIME_ZONE = 'America/Sao_Paulo'

USE_I18N = True

USE_L10N = True

USE_TZ = True


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

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


# Simplified static file serving.
# https://warehouse.python.org/project/whitenoise/
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'

FILE_UPLOAD_HANDLERS = ['django.core.files.uploadhandler.TemporaryFileUploadHandler']

# Extra places for collectstatic to find static files.
STATICFILES_DIRS = (
    os.path.join(PROJECT_ROOT, 'static'),
)


# Update database configuration with $DATABASE_URL.
db_from_env = dj_database_url.config(conn_max_age=500)
DATABASES['default'].update(db_from_env)


# Honor the 'X-Forwarded-Proto' header for request.is_secure()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

LOGIN_URL = '/login/'
LOGIN_REDIRECT_URL = '/dashboard/'

DEFAULT_CONTACT_EMAIL = str(os.environ.get('EMAIL_ACCOUNT'))
DEFAULT_FROM_EMAIL = str(os.environ.get('EMAIL_ACCOUNT'))
EMAIL_HOST_USER = str(os.environ.get('EMAIL_ACCOUNT'))
EMAIL_HOST_PASSWORD = str(os.environ.get('EMAIL_PASSWORD'))
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
SERVER_EMAIL = str(os.environ.get('EMAIL_ACCOUNT'))

ADMINS = [('Admin', str(os.environ.get('ADMIN_ACCOUNT'))), ]


# Moderation Hours
ENABLE_MOD_SHIFT = False

# Facebook Stuff
FACEBOOK_KEY = os.environ.get('FACEBOOK_KEY')
FACEBOOK_SECRET = os.environ.get('FACEBOOK_SECRET')
FACEBOOK_PAGE_TOKEN = os.environ.get('FACEBOOK_PAGE_TOKEN')
FACEBOOK_PERMISSIONS = []

# Page Stuff
INITIAL_COUNT = os.environ.get('INITIAL_COUNT')

# Google Captcha stuff
RECAPTCHA_PUBLIC_KEY = os.environ.get('RECAPTCHA_PUBLIC_KEY')
RECAPTCHA_PRIVATE_KEY = os.environ.get('RECAPTCHA_PRIVATE_KEY')
NOCAPTCHA = True

# Imgur stuff
IMGUR_CLIENT = os.environ.get('IMGUR_CLIENT', False)
IMGUR_SECRET = os.environ.get('IMGUR_SECRET', False)

# Web Of Trust
WOT_SECRET = os.environ.get('WOT_SECRET')

# Google Safe Browsing
GSB_SECRET = os.environ.get('GSB_SECRET')

# Spotted API
SPOTTED_API_URL = "http://spottedapi.herokuapp.com"
SPOTTED_API_SECRET = os.environ.get('SPOTTED_API_SECRET')

# Adsense

# Please do not alter the dev ads, as I provide you with free code and API support for you to make money. Allow me a share out of it :)
DEV_AD = "ca-pub-2287814566368449"
SPOTTED_AD = os.environ.get('SPOTTED_AD', False)
ADS_ACTIVE = eval(os.environ.get('ADS_ACTIVE', 'False'))
AD_TEST = eval(os.environ.get('AD_TEST', 'False'))
AD_SLOTS = eval(os.environ.get('AD_SLOTS', '[]')) or (["slot 1", "slot 2", "slot 3"] if AD_TEST else [])
ADS_APPROVED = True if AD_SLOTS else False

@@ -854,19 +854,20 @@
 DEBUG = 
-Tru
+Fals
 e%0A%0AALLOW

debug off