"""
Using Django 1.10.3.
"""

from __future__ import absolute_import, unicode_literals

import os
import sys
import raven

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

# Application definition
reload(sys)
sys.setdefaultencoding('utf-8')

ALLOWED_HOSTS = ['*']

SECRET_KEY = '3rsf0d&@7@in(ia4k%dyhrde(birxw2dn-_l$#y#wqz_qnkqgr'


PROJECT_APPS = [
    'users',
    'main',
    'products',
    'payment',
    'orders',
    'notifications',
    'search',
    'dashboard'
]

THIRD_PARTY_APPS =[
    'modelcluster',
    'taggit',
    'raven.contrib.django.raven_compat',
]

WAGTAIL_APPS = [
    'wagtail.wagtailforms',
    'wagtail.wagtailredirects',
    'wagtail.wagtailembeds',
    'wagtail.wagtailsites',
    'wagtail.wagtailusers',
    'wagtail.wagtailsnippets',
    'wagtail.wagtaildocs',
    'wagtail.wagtailimages',
    'wagtail.wagtailsearch',
    'wagtail.wagtailadmin',
    'wagtail.wagtailcore',
    'wagtail.contrib.modeladmin',
    'wagtail.contrib.settings'
]

DJANGO_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.humanize'
]

INSTALLED_APPS = PROJECT_APPS + THIRD_PARTY_APPS + WAGTAIL_APPS + DJANGO_APPS

ROOT_URLCONF = 'padawan.urls'

WSGI_APPLICATION = 'padawan.wsgi.application'

WAGTAIL_SITE_NAME = "UgyShop"

AUTH_USER_MODEL = 'users.User'

WAGTAIL_USER_EDIT_FORM = 'users.forms.CustomUserEditForm'

WAGTAIL_USER_CREATION_FORM = 'users.forms.CustomUserCreationForm'

WAGTAIL_USER_CUSTOM_FIELDS = ['telephone_number', 'id_type', 'id_number']

#Middlewares
MIDDLEWARE = [
    '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',
    'django.middleware.security.SecurityMiddleware',

    'wagtail.wagtailcore.middleware.SiteMiddleware',
    'wagtail.wagtailredirects.middleware.RedirectMiddleware',
]

#Template config
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            os.path.join(PROJECT_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',
                'wagtail.contrib.settings.context_processors.settings',
                'main.context_processors.main_processor'
            ],
        },
    },
]


# Internationalization
LANGUAGE_CODE = 'es-CO'

TIME_ZONE = 'America/Bogota'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Statics config
STATICFILES_FINDERS = [
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
]

STATICFILES_DIRS = [
    os.path.join(PROJECT_DIR, 'static'),
]


STATIC_URL = '/static/'
MEDIA_URL = '/media/'


#PayU config
PAYU_SANDBOX_MODE = True # Set to True for testing and False for production.

#CACHE config
CACHES = {
    'default': {
        'BACKEND': 'django_redis.cache.RedisCache',
        'LOCATION': '127.0.0.1:6379',
        'OPTIONS': {
            'CLIENT_CLASS': 'django_redis.client.DefaultClient',
        }
    }
}


RAVEN_CONFIG = {
    'dsn': 'https://32ffc687f1994394bd535ae9c80bad93:1aed4abbe8f7463899deefa8f38387bd@sentry.io/125020',
    # If you are using git, you can also automatically configure the
    # release based on the git info.
    'release': raven.fetch_git_sha(os.path.dirname('/home/django/UgyShop/padawan')),
}
