"""
Django settings for coin_dev project.

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

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

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

import os
from coin_dev.secret import *
# toekn api key 관련 정보는 secret.py 저장


# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
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/2.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production 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',
    'rest_framework',
    'account',
    'order',
#    'public',
#    'transaction',
    'users',
    'schedules',

]

# import sys
# if 'test' in sys.argv:
#     DATABASES = {
#         'default': {
#             'ENGINE': 'django.db.backends.sqlite3',
#             'NAME': os.path.join(os.path.dirname(__file__), 'test.db'),
#             'TEST_NAME': os.path.join(os.path.dirname(__file__), 'test.db'),
#         }
#     }

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 = 'coin_dev.urls'


WSGI_APPLICATION = 'coin_dev.wsgi.application'

REST_FRAMEWORK = {
    'DEFAULT_RENDERER_CLASSES': (
        'rest_framework.renderers.JSONRenderer',
        'rest_framework.renderers.BrowsableAPIRenderer',
    ),
    'DEFAULT_PARSER_CLASSES': (
        'rest_framework.parsers.JSONParser',
    ),
    "DEFAULT_PERMISSION_CLASSES": (
        'rest_framework.permissions.AllowAny',
        # 'rest_framework.permissions.IsAuthenticated',
        # 'rest_framework.permissions.IsAuthenticatedOrReadOnly'
    ),
}
# REST_FRAMEWORK = {
#     'DEFAULT_METADATA_CLASS': 'rest_framework.metadata.SimpleMetadata'
# }
AUTHENTICATION_BACKENDS = [
    'django.contrib.auth.backends.ModelBackend'
]
#
# if DEBUG:
#   INTERNAL_IPS = ('127.0.0.1', )
#   MIDDLEWARE += (
#     'debug_toolbar.middleware.DebugToolbarMiddleware',
#   )
#   INSTALLED_APPS += (
#     'debug_toolbar',
#   )
#   DEBUG_TOOLBAR_PANELS = [
#     'debug_toolbar.panels.versions.VersionsPanel',
#     'debug_toolbar.panels.timer.TimerPanel',
#     'debug_toolbar.panels.settings.SettingsPanel',
#     'debug_toolbar.panels.headers.HeadersPanel',
#     'debug_toolbar.panels.request.RequestPanel',
#     'debug_toolbar.panels.sql.SQLPanel',
#     'debug_toolbar.panels.staticfiles.StaticFilesPanel',
#     'debug_toolbar.panels.templates.TemplatesPanel',
#     'debug_toolbar.panels.cache.CachePanel',
#     'debug_toolbar.panels.signals.SignalsPanel',
#     'debug_toolbar.panels.logging.LoggingPanel',
#     'debug_toolbar.panels.redirects.RedirectsPanel',
#   ]
#   DEBUG_TOOLBAR_CONFIG = {
#     'INTERCEPT_REDIRECTS': False,
# }


CORS_ORIGIN_ALLOW_ALL = True
CORS_ALLOW_CREDENTIALS = False
CORS_ALLOW_HEADERS = (
    'accept',
    'accept-encoding',
    'authorization',
    'content-type',
    'cache-control',
    'pragma',
    'dnt',
    'origin',
    'user-agent',
    'x-csrftoken',
    # 'x-requested-with',
    # 'x-frame-options',
    # 'access-control-allow-origin',
)
CORS_ALLOW_METHODS = (
    'DELETE',
    'GET',
    'OPTIONS',
    'PATCH',
    'POST',
    'PUT',
)


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

# DATABASES = {
#     'default':{
#         'ENGINE': 'django.db.backends.postgresql_psycopg2',
#         'NAME': 'postgres',
#         'USER': 'sa',
#         'PASSWORD': 'coinonetest05',
#         'HOST': '172.0.0.1',
#         'PORT': '5432',
#     }
# }


# Password validation
# https://docs.djangoproject.com/en/2.0/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/2.0/topics/i18n/

LANGUAGE_CODE = 'en-us'
#TIME_ZONE = 'UTC'
TIMEZONE = 'Asia/Seoul'
USE_I18N = True
USE_L10N = True
USE_TZ = True


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

STATIC_URL = '/static/'

###############################Custom User Model###############################
#AUTH_USER_MODEL = 'users.usermaster'
AUTH_USER_MODEL = 'users.Usermaster'

###############################CELERY settigns###############################
BROKER_URL = 'redis://localhost:6379/0'
CELERY_RESULT_BACKEND = 'redis://localhost:6379/0'
CELERY_BROKER_URL = 'redis://localhost:6379/0'

###############################coinone_api###############################
BASE_URL = 'https://api.coinone.co.kr/'
BASE_URL_v2 = 'https://api.coinone.co.kr/v2/'

COINONE_ORDERBOOK = BASE_URL + 'orderbook/'
COINONE_TICKER = BASE_URL + 'ticker/'
COINONE_ACCOUNT_BALANKCE = BASE_URL_v2 + 'account/balance/'
COINONE_ACCOUNT_USER_INFO = BASE_URL_v2 + 'account/user_info/'
COINONE_ORDER_LIMIT_BUY = BASE_URL_v2 + 'order/limit_buy/'
COINONE_ORDER_LIMIT_SELL = BASE_URL_v2 + 'order/limit_sell/'
COINONE_ORDER_CANCEL = BASE_URL_v2 + 'order/cancel/'
COINONE_ORDER_INFO = BASE_URL_v2 + 'order/order_info/'

