"""
Django settings for dj_dpv project.

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

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

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

import os

from os.path import join, normpath
from configparser import RawConfigParser

PROJECT_NAME = 'dpv'

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

# ini config
FILE_CONFIG_NAME = '{}.ini'.format(PROJECT_NAME)
CONFIG_FILE = '/etc/{}/{}'.format(PROJECT_NAME, FILE_CONFIG_NAME)

config = RawConfigParser()
if os.path.isfile(CONFIG_FILE):
    config.read(CONFIG_FILE)
else:
    config.read(os.path.join(SITE_ROOT, 'etc', FILE_CONFIG_NAME))

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

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = config.get('secrets', 'APP_KEY')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = config.get('debug', 'DEBUG')

SITE_ID = config.get('info', 'SITE_ID')

# Twitter
# Go to http://apps.twitter.com and create an app.
# The consumer key and secret will be generated for you after
TWITTER_CONSUMER_KEY = config.get('twitter', 'TWITTER_CONSUMER_KEY')
TWITTER_CONSUMER_SECRET = config.get('twitter', 'TWITTER_CONSUMER_SECRET')

# After the step above, you will be redirected to your app's page.
# Create an access token under the the "Your access token" section
TWITTER_ACCESS_TOKEN = config.get('twitter', 'TWITTER_ACCESS_TOKEN')
TWITTER_ACCESS_TOKEN_SECRET = config.get('twitter', 'TWITTER_ACCESS_TOKEN_SECRET')

ALLOWED_HOSTS = []


# Application definition

PROJECT_APPS = [
    'api',
    'core',
    'dashboard'
]

THIRD_APPS = [
    'rest_framework'
]

INSTALLED_APPS = PROJECT_APPS + THIRD_APPS + [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
]

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 = 'dj_dpv.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 = 'dj_dpv.wsgi.application'


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

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': config.get('database', 'DBNAME'),
        'USER': config.get('database', 'DBUSER'),
        'PASSWORD': config.get('database', 'DBPWD'),
        'HOST': config.get('database', 'DBHOST'),
        'PORT': config.get('database', 'DBPORT'),
    }
}


# Password validation
# https://docs.djangoproject.com/en/1.11/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.11/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.11/howto/static-files/

STATIC_URL = '/static/'

PESO_INFO_FROM = 'http://valordeldolar.cl/'
BS_INFO_FROM = 'dolartoday'

# RestFramwork
REST_FRAMEWORK = {
    # Use Django's standard `django.contrib.auth` permissions,
    # or allow read-only access for unauthenticated users.
    'DEFAULT_PERMISSION_CLASSES': [
        # 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
    ]
}

# URLs
CORE_URL = config.get('urls', 'CORE_URL')
CORE_PORT = config.get('urls', 'CORE_PORT')
URL_CORE = 'http://{}:{}'.format(CORE_URL, CORE_PORT)
URL_API = URL_CORE + '/api/'

"""
Django settings for dj_dpv project.

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

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

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

import os

from os.path import join, normpath
from configparser import RawConfigParser

PROJECT_NAME = 'dpv'

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

# ini config
FILE_CONFIG_NAME = '{}.ini'.format(PROJECT_NAME)
CONFIG_FILE = '/etc/{}/{}'.format(PROJECT_NAME, FILE_CONFIG_NAME)

config = RawConfigParser()
if os.path.isfile(CONFIG_FILE):
    config.read(CONFIG_FILE)
else:
    config.read(os.path.join(SITE_ROOT, 'etc', FILE_CONFIG_NAME))

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

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = config.get('secrets', 'APP_KEY')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = config.get('debug', 'DEBUG')

SITE_ID = config.get('info', 'SITE_ID')

# Twitter
# Go to http://apps.twitter.com and create an app.
# The consumer key and secret will be generated for you after
TWITTER_CONSUMER_KEY = config.get('twitter', 'TWITTER_CONSUMER_KEY')
TWITTER_CONSUMER_SECRET = config.get('twitter', 'TWITTER_CONSUMER_SECRET')

# After the step above, you will be redirected to your app's page.
# Create an access token under the the "Your access token" section
TWITTER_ACCESS_TOKEN = config.get('twitter', 'TWITTER_ACCESS_TOKEN')
TWITTER_ACCESS_TOKEN_SECRET = config.get('twitter', 'TWITTER_ACCESS_TOKEN_SECRET')

ALLOWED_HOSTS = []


# Application definition

PROJECT_APPS = [
    'api',
    'core',
    'dashboard'
]

THIRD_APPS = [
    'rest_framework'
]

INSTALLED_APPS = PROJECT_APPS + THIRD_APPS + [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
]

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 = 'dj_dpv.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 = 'dj_dpv.wsgi.application'


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

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': config.get('database', 'DBNAME'),
        'USER': config.get('database', 'DBUSER'),
        'PASSWORD': config.get('database', 'DBPWD'),
        'HOST': config.get('database', 'DBHOST'),
        'PORT': config.get('database', 'DBPORT'),
    }
}


# Password validation
# https://docs.djangoproject.com/en/1.11/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.11/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.11/howto/static-files/

STATIC_URL = '/static/'

PESO_INFO_FROM = 'http://valordeldolar.cl/'
BS_INFO_FROM = 'dolartoday'

# RestFramwork
REST_FRAMEWORK = {
    # Use Django's standard `django.contrib.auth` permissions,
    # or allow read-only access for unauthenticated users.
    'DEFAULT_PERMISSION_CLASSES': [
        # 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
    ]
}

# URLs
CORE_URL = config.get('urls', 'CORE_URL')
CORE_PORT = config.get('urls', 'CORE_PORT')
URL_CORE = 'http://{}:{}'.format(CORE_URL, CORE_PORT)
URL_API = URL_CORE + '/api/'

Django settings for dj_dpv project.  Generated by 'django-admin startproject' using Django 1.11.5.  For more information on this file, see https://docs.djangoproject.com/en/1.11/topics/settings/  For the full list of settings and their values, see https://docs.djangoproject.com/en/1.11/ref/settings/ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) # ini config # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! # SECURITY WARNING: don't run with debug turned on in production! # Twitter # Go to http://apps.twitter.com and create an app. # The consumer key and secret will be generated for you after # After the step above, you will be redirected to your app's page. # Create an access token under the the "Your access token" section # Application definition # Database # https://docs.djangoproject.com/en/1.11/ref/settings/#databases # Password validation # https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators # Internationalization # https://docs.djangoproject.com/en/1.11/topics/i18n/ # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.11/howto/static-files/ # RestFramwork # Use Django's standard `django.contrib.auth` permissions, # or allow read-only access for unauthenticated users. # 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly' # URLs