"""
Django settings for walladog project.

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

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/
"""

# 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__)))


# 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 = '=e8m1h9)0lazq)%7bcho@a9w^_kfd)_plf_teg8_jp^ax9&k!p'

# 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',

    #proyect apps
    'categories',
    'images',
    'products',
    'races',
    'saveserches',
    'states',
    'transactions',
    'users',
    'walladog',

    #Rest_framework
    'rest_framework',
    'oauth2_provider',
    'corsheaders',
    'django.contrib.gis',
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'corsheaders.middleware.CorsMiddleware',
    '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 = 'walladog.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',
            ],
        },
    },
]

WSGI_APPLICATION = 'walladog.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
DATABASES = {
    'default': {
        'ENGINE': 'django.contrib.gis.db.backends.mysql',
        'NAME': 'walladog_dev',
        'USER': 'walladog',
        'PASSWORD': 'Keepcoding123',
        'HOST': 'mysql.develjitsu.com',
        'PORT': '3306',
    },
    # 'prod': {
    #     'ENGINE': 'django.db.backends.mysql',
    #     'NAME': 'walladog',
    #     'USER': 'walladog',
    #     'PASSWORD': 'xxx',
    #     'HOST': 'mysql.develjitsu.com',
    #     'PORT': '3306',
    # },
}

# POR SI QUEREIS TRABAJAR EN LOCAL CON SQLITE
# 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 = 'es-es'

# TIME_ZONE = 'UTC'
# Europe/Madrid
TIME_ZONE = 'Europe/Madrid'

USE_I18N = True

USE_L10N = True

USE_TZ = True

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

# REST FRAMEWORK
REST_FRAMEWORK = {
    'EXCEPTION_HANDLER': 'rest_framework.views.exception_handler',
    'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'oauth2_provider.ext.rest_framework.OAuth2Authentication',
    ),
    'DEFAULT_PERMISSION_CLASSES': (
        'rest_framework.permissions.IsAuthenticated',
    ),
    'DEFAULT_METADATA_CLASS': 'rest_framework.metadata.SimpleMetadata'
}

OAUTH2_PROVIDER = {
    # this is the list of available scopes
    'SCOPES': {
        'read': 'Read scope',
        'write': 'Write scope',
        'groups': 'Access to your groups'}
}

# CORS
# APPEND_SLASH = False
CORS_ORIGIN_ALLOW_ALL = True
CORS_ORIGIN_WHITELIST = (
    'http://localhost:9000',
    'http://www.walladog.com',
    'walladog.com'
)
# CORS_URLS_REGEX = r'^/api/.*$'

STATIC_URL = '/static/'

# DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'


#
# AWS_ACCESS_KEY_ID = 'AKIAJYDV7TEBJS6JWEEQ'
# AWS_SECRET_ACCESS_KEY = '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'
# AWS_STORAGE_BUCKET_NAME = 'walladog'


# AWS_QUERYSTRING_AUTH = False
# AWS_ACCESS_KEY_ID = os.environ['AKIAJYDV7TEBJS6JWEEQ']
# AWS_SECRET_ACCESS_KEY = os.environ['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']
# AWS_STORAGE_BUCKET_NAME = os.environ['walladog']
# MEDIA_URL = 'http://%s.s3.amazonaws.com/' % AWS_STORAGE_BUCKET_NAME
# DEFAULT_FILE_STORAGE = "storages.backends.s3boto.S3BotoStorage"