"""
Django settings for datacenter project.

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

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

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



# 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 = '#bt&r7&_sgnw5)6gjcervgu$#&3t@j=iix&r2faosv$#12$_+m'

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

'''
ALLOWED_HOSTS = [
    '47.107.230.103',
    '127.0.0.1',
]
'''
ALLOWED_HOSTS = ['*']


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'company',
    'inventory',    
    'product',
    'rest_framework',
    'pure_pagination',
    'django_filters',
    'django_extensions',
    'promotion',
]


REST_FRAMEWORK = {
    # Use Django's standard <code>django.contrib.auth</code> permissions,
    # or allow read-only access for unauthenticated users.
    'DEFAULT_PERMISSION_CLASSES': [
        'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly',
     ],
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework.authentication.BasicAuthentication',
        'rest_framework.authentication.SessionAuthentication',
    ),
    'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',  
    'DEFAULT_FILTER_BACKENDS': (
        'rest_framework.filters.SearchFilter',
        'rest_framework.filters.OrderingFilter',
        'django_filters.rest_framework.backends.DjangoFilterBackend',
    ),
    'PAGE_SIZE': 2,
}

PAGINATION_SETTINGS = {
    'PAGE_RANGE_DISPLAYED': 10,
    'MARGIN_PAGES_DISPLAYED': 2,
    'SHOW_FIRST_PAGE_WHEN_INVALID': True,
}




MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',    
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.context_processors.auth',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',    
    'django.contrib.messages.middleware.MessageMiddleware',
    #'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    


]   

ROOT_URLCONF = 'datacenter.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates').replace('\\', '/'),],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',               
                'django.contrib.auth.context_processors.auth',
                #'django.contrib.auth.context_processors.PermWrapper',  
                'django.contrib.messages.context_processors.messages',
                              
                               
            ],
            'libraries':{
                "tj_filters":"templatetags.tj_filters",
            },
        },

    },
]

WSGI_APPLICATION = 'datacenter.wsgi.application'


# 本地服务器
DATABASES = {      
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'datacenter',
        'USER': 'acc',
        'PASSWORD': '123',
        'HOST': 'localhost',
        'PORT': '5432',
        'OPTIONS': {
            'options': '-c search_path=logistics'
        },
    },   

}

AUTH_USER_MODEL = 'company.User' 

# 2018-11-23
JG_K = '#d&pjy!fi@0'
# 20119-06-15
# 酒鬼传承，发货同步到透云
SYNC_JG_TY =True
SYNC_JG_TY =False

# 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 = 'zh_Hans'
TIME_ZONE = 'Asia/Shanghai'


#DATETIME_FORMAT = 'Y-m-d H:i:s'
#DATE_FORMAT = 'Y-m-d'

USE_I18N = True

USE_L10N = True

# USE_TZ = True  当设置了 USE_TZ 为 True 时，Django 与其他系统或服务的交流将强制使用 UTC 时间
USE_TZ = False



'''
LANGUAGES = (
    ('en', ('English')),
    ('zh-Hans', ('中文简体')),
    ('zh-Hant', ('中文繁體')),    
)
'''



LOCALE_PATHS = (
    os.path.join(BASE_DIR, "locale"),
)

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



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



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


MEDIA_ROOT=os.path.join(BASE_DIR,'media')
MEDIA_URL = '/media/'

WULIU_STR = 'DRIVER={SQL Server};SERVER=117.34.70.23,33419;DATABASE=TianJianWuLiuWebnew;UID=jk;PWD=tianjian2019'
TY_WULIU_STR = 'dbname=wuliu    user=wuliuadmin password=china315net#compg2017 host=116.62.122.204 port=25227'
CRM_STR = 'dbname=tianjianjishi user=wuliuadmin password=china315net#compg2017 host=116.62.122.204 port=25227'

GIS_STR = 'dbname=gis user=acc password=123 host=117.34.70.23 port=5432'



SPECIAL_COMPANIES = []


TY_PRODUCTS_ID={
    32: {'name':'39度500mL酒鬼酒（传承）',          'wl_id':4338},
    33 :{'name':'39度500mL酒鬼酒（传承）（2*2）',   'wl_id':4339},
    410:{'name':'52度500ML酒鬼酒（传承）',          'wl_id':4335},
    412:{'name':'52度500ml酒鬼酒（传承）（2X2）',   'wl_id':4340}, 
    373:{'name':'52度500mL红坛酒鬼酒（高度柔和）',  'wl_id':4066},  
}





