#!/usr/bin/python
# -*- coding:utf-8 -*-
"""
Django settings for formu project.

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

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 = '06!s0z-1p+ejt#qaqd&$el#79m6o66hc=dt0g2t^es!09q77ni'

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

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

ROOT_URLCONF = 'formu.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'forum/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 = 'formu.wsgi.application'

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

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

AUTH_USER_MODEL = 'forum.ForumUser'
# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/

LANGUAGE_CODE = 'zh-CN'

TIME_ZONE = 'Asia/Shanghai'

USE_I18N = True

USE_L10N = True

USE_TZ = True

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


# 保留用户名
RESERVED = ["user", "topic", "home", "setting", "forgot", "login", "logout", "register", "admin"]
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
# AUTHENTICATION_BACKENDS = ('forum.views.backends.EmailAuthBackend',)
# 登陆设置
LOGIN_URL = '/login/'

# 发送邮件设置
EMAIL_HOST = 'smtp.163.com'
EMAIL_PORT = 25
EMAIL_HOST_USER = 'dunchen914@163.com'
EMAIL_HOST_PASSWORD = 'vrlrfsyhiaszcrzi'
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER

TEMPLATE_DIRS = (
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
)

TEMPLATE_CONTEXT_PROCESSORS = (  # F2E中有current_user对象和request对象,这里设置可在模板中使用RquestContext
    'django.contrib.auth.context_processors.auth',  # user对象等等
    'django.core.context_processors.request',  # request对象等等
    'django.core.context_processors.static',  # 在模板中使用{{ STATIC_URL }}获取静态文件路径
    'forum.context_processors.custom_proc',  # 自定义模板上下文处理器
)

#PROJECT_ROOT = os.path.join(os.path.abspath(os.path.dirname(__file__)), '..')

STATIC_ROOT = os.path.join(BASE_DIR, 'static')

STATIC_URL = '/static/'

STATICFILES_DIRS = (
    ("css", os.path.join(STATIC_ROOT, 'bootstrap/css')),
    ("js", os.path.join(STATIC_ROOT, 'bootstrap/js')),
    ("images", os.path.join(STATIC_ROOT, 'bootstrap/imgages')),
)
