# -*- coding:utf-8 -*-
"""
Django settings for admin project.

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

For more informdation 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, sys

BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
# PROJECT_ROOT = os.path.realpath(os.path.dirname(__file__))
# sys.path.insert(0, os.path.join(PROJECT_ROOT, os.pardir))
# sys.path.insert(0, os.path.join(os.path.dirname(PROJECT_ROOT), "site-packages"))
sys.path.insert(0, os.path.join(BASE_DIR, 'apps'))  # 将apps、extra_apps加入到path路径中
sys.path.insert(0, os.path.join(BASE_DIR, 'extra_apps'))


# 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 = '7#s=eh&=lrna8c1ulh(_fmu2q7ert4fh994_t!#2e7$iauhpp('

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

ALLOWED_HOSTS = ['*']


# Application definition

INSTALLED_APPS = (
    'django_crontab',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'detail',
    'users',
    'operations',
    'scanhosts',
    'taskdo',
    # 'extra_apps.xadmin',
    'crispy_forms',
)
SITE_ID = 1


MIDDLEWARE_CLASSES = (
    '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',
    'users.middleware.UrlMiddelware',
)


ROOT_URLCONF = 'admin.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_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',
            ],
        },
    },
]

WSGI_APPLICATION = 'admin.wsgi.application'


# DATABASES = {
#     'default': {
#         'ENGINE': 'django.db.backends.mysql',
#         'NAME': 'imoocc',
#         'USER': 'imoocc',
#         'PASSWORD': 'imoocccom',
#         'HOST': '127.0.0.1',
#         'PORT': '',
#         'OPTIONS': {},
#         'init_command': 'SET storage_engine=INNODB,'
#                         'SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED, autocommit=1, names "utf8";',
#     }
# }
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'cmdb_v1',
        'USER': 'xl',
        'PASSWORD': 'HWS@5tgb',
        'HOST': '127.0.0.1',
        'PORT': '',
        'OPTIONS': {},
        'init_command': 'SET storage_engine=INNODB,'
                        'SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED, autocommit=1, names "utf8";',
    }
}

LANGUAGE_CODE = 'zh-Hans'

TIME_ZONE = 'Asia/Shanghai'

USE_I18N = True

USE_L10N = True

USE_TZ = False


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

STATIC_URL = '/static/'
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static')
]

# Email settings smtp/pop3
EMAIL_HOST = "smtp.163.com"
EMAIL_HOST_USER = "xxx@email.com"
EMAIL_HOST_PASSWORD = "123456"
EMAIL_USE_TLS = False
EMAIL_SUBJECT_PREFIX = u"[邮件]"


# loging
LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'verbose': {
            'format': '[%(levelname)1.1s %(asctime)s %(module)s:%(lineno)d] %(message)s',
            'datefmt': '%Y%m%d %H:%M:%S',
        },
    },
    'handlers': {
        'file': {
            'level': 'INFO',
            'class': 'logging.FileHandler',
            'formatter': 'verbose',
            'filename': '%s/error.logs'%BASE_DIR,
        },
    },
    'loggers': {
        'django': {
            'handlers': ['file'],
            'level': 'INFO',
            'propagate': True,
        },
    },
}

# Mongo DB
# MONGO_HOST = '192.168.1.108'
# MONGO_PORT = '27017'

# Redis Con
# REDSI_KWARGS_LPUSH = {"host":'192.168.1.108','port':6379,'db':3}
# REDSI_LPUSH_POOL = None