"""
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 redis
import os
from django.utils.translation import gettext_lazy as _

# 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
#测试用true

DEBUG = False
#生产环节用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',
    'sales',
    'wx',
    'mall',
    'django_prbac',
    'djcelery',
    'entertainment',
    'rbac',
    'mes',
    'thirdparty',
    'erp',
    'banquet',
    'extra',
    
    #'system',
]


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,
}


#2021-12-25
WHITE_URL_LIST = [
    r'^/admin/.*',          # 放行admin应用url
    r'^/rbac/login/',
    r'^/rbac/register/',
    r'^/rbac/get_auth_img/',
]





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',
    '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.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': '47.107.230.103',
        'PORT': '5432',
        'OPTIONS': {
            'options': '-c search_path=logistics'
        },
    },   

}


AUTH_USER_MODEL = 'company.User' 

# 2018-11-23
JG_K = '#d&pjy!fi@0'


#2021-11-17
internal_Sk='$internal&GLker5w3jtQLx#'


# 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/


#2020-12-26 注释掉
#LANGUAGE_CODE = 'zh_Hans'



LANGUAGES = [
    ('zh-Hans', _('Chinese')),
]
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}, 
    #2020-05-11，酒鬼罗工
    867:{'name':'52度500mL红坛酒鬼酒（20）',        'wl_id':4066},  
    #2020-06-05，酒鬼罗工
    942:{"name":"52度500mL酒鬼酒（传承）（2*2）普通版","wl_id":4343},
    940:{"name":"39度500mL酒鬼酒（传承）（2*2）普通版","wl_id":4344},    
    #2020-06-15，酒鬼罗工
    1071:{"name":"52度500mL紫坛酒鬼酒（2020版）","wl_id":4345}, 



    #2020-07-29 酒鬼罗工
    1080:{"name":'54度500ml酒鬼酒（传承）（1956）','wl_id':4346},
    1089:{"name":'42度500ml酒鬼酒（传承）（1987）','wl_id':4347},  
    1091:{"name":'52度500mL红坛酒鬼酒（18）','wl_id':4348},


    #2020-09-02 透云
    1112:{"name":'测试紫坛活动1','wl_id':200000},
    1113:{"name":'测试紫坛活动2','wl_id':200001}, 


    #2020-10-10 L(罗天雄)
    1075:{"name":"42度500mL红坛酒鬼酒（20）",           'wl_id':4352},
    1118:{"name":"52度500mL红坛酒鬼酒（20）（2*2）",    'wl_id':4353},
    1126:{"name":"52度500mL酒鬼酒（馥郁经典）",         'wl_id':4354},

    #2020-12-29 罗工邮件
    1184:{"name":"52度500mL黄坛酒鬼酒（12）",           'wl_id':4355},



    #2021-04-12 罗工微信
    1390:{"name":"52度500mL酒鬼酒（透明装）（鉴赏）",    'wl_id':4364},
    1391:{"name":"42度500mL酒鬼酒（透明装）（鉴赏）",    'wl_id':4365},    

}





JG_HT_GR={
    49:{
        'product':"42度500mL红坛酒鬼酒（恬柔拾伍）",
        'jxname':u'19.9红包',
        'remarks':'19.9',
        'jxid':'55',
        'compid':'99',
        'code':'G',
        'pid':'XinBanTR',
        'jgflag':u"'恬柔'"
    },
    50:{
        'product':"42度500mL红坛酒鬼酒（恬柔拾伍）（2*2）",
        'jxname':u'19.9红包',
        'remarks':'19.9',
        'jxid':'55',
        'compid':'99',
        'code':'G',
        'pid':'XinBanTR',
        'jgflag':u"'恬柔'"
    },
    373:{
        'product':"52度500mL红坛酒鬼酒（高度柔和）",
        'jxname':u'19.9红包',
        'remarks':'19.9',
        'jxid':'55',
        'compid':'99',
        'code':'G',
        'pid':'XinBan',
        'jgflag':'null'        
    },
    374:{       
        'product':"52度500ml红坛酒鬼酒（高度柔和）（2*2）",
        'jxname':u'19.9红包',
        'remarks':'19.9',
        'jxid':'55',
        'compid':'99',
        'code':'G',
        'pid':'XinBan',
        'jgflag':'null'     
    }
}



#2019-12-19
WX={
    "appid": "wxe9a919e0d3c419ee",
    "appsecret": "d220dc13fd5e239677a33555945ec810",
    "url_jscode2session": "https://api.weixin.qq.com/sns/jscode2session?appid={appid}&secret={appsecret}&js_code={jscode}&grant_type=authorization_code",
    "url_oauth": "https://open.weixin.qq.com/connect/oauth2/authorize?appid={appid}&redirect_uri={redirect_url}&response_type={response_type}&scope={scope}&state={state}#wechat_redirect",   
    "url_access_token":"https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wxe9a919e0d3c419ee&secret=d220dc13fd5e239677a33555945ec810",
    "url_access_token_fmt":"https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={0}&secret={1}",
    "url_oauth_access_token":'https://api.weixin.qq.com/sns/oauth2/access_token?appid={0}&secret={1}&code={2}&grant_type=authorization_code',
    "url_ticket_fmt":"https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token={0}&type=jsapi",
}

WX_TJFW={    
    'app_id':'wx59969257ee0275da',
    'app_secret':'55eb57c3af0fdc86b8273d0d286c8ba0',
    'wx_official_account_id':'6',
    'oauth_direct_url_prefix':'http://tjfnew.china315net.com/wxsqroute.html?'        
}
WX_JG={
    'app_id':'wx67fd227a8fa5729d',
    'app_secret':'9e182af51543d94eb7047e801f6d01e2',
    'wx_official_account_id':'1',
    'oauth_direct_url_prefix':'http://tjfnew.china315net.com/wxsqroute.html?'
}
#2020-09-18 内参名人堂
WX_NC={    
    'app_id':'wx333e44a3245b685e',
    'app_secret':'4226cb0b2c3b78d7e33ef67b95abc654',
    'wx_official_account_id':'7',
    #'oauth_direct_url_prefix':'http://tjfnew.china315net.com/wxsqroute.html?'        
}

#2020-12-12 
WX_SALT='d8R%0t7s#wc'



#2020-05-01
CN_AL='DRIVER={SQL Server};SERVER=116.62.122.204,33417;DATABASE=ZJFW;UID=ali01;PWD=china315netcom2017))'
CN_XA='DRIVER={SQL Server};SERVER=117.34.70.23,33419;DATABASE=TJMarketingSystemYin;UID=jk;PWD=tianjian2019'


#2020-07-06 消费者扫码COOKIE
TJ_CK_UID='TJWXUSR'



#2020-07-10
RD={'password':'tjredis139','port':16379}
LABEL_CHECK_POOL=       redis.ConnectionPool(host='127.0.0.1',port=16379,db=2, password='tjredis139', decode_responses=True)
LABEL_PRODUCT_POOL=     redis.ConnectionPool(host='127.0.0.1',port=16379,db=4, password='tjredis139', decode_responses=True)
BOTTLECAP_BINDING_POOL= redis.ConnectionPool(host='127.0.0.1',port=16379,db=10,password='tjredis139', decode_responses=True)
#rd=redis.StrictRedis(host='localhost', port=settings.RD['port'], db=10, password=settings.RD['password'], decode_responses=True) 


#2020-10-13 百度地图AK
BD_URL='https://api.map.baidu.com/geocoder/v2/?ak=ASl2xmUaYpjwdWy3GPBQbpUK'

#2020-12-18
INTERFACE_KEY = 'cvWcgIEX4woyftZpddQVRYP2SNQDBkFt'





#2022-02-25 内网地址
INTERNAL_URL='http://www.china315net.com:35088/get/codes/from/wuliu/1/'
INTERNAL_SK='$internal&GLker5w3jtQLx#'








#############################
# celery 配置信息 start
#############################
import djcelery
djcelery.setup_loader()
CCELERY_TIMEZONE = 'Asia/Shanghai'
CELERY_IMPORTS = ('taskman.tasks')  # 指定celery任务文件
#BROKER_URL = 'redis://:tjredis139@localhost:16379/9'
#BROKER_URL='mqp://guest@localhost//'
BROKER_URL='amqp://tj_rabbit:QWER@localhost//'

CELERY_TASK_SERIALIZER = 'json'



'''
#session存储到redis
#pip install django-redis
CACHES = {
    "default": {
        "BACKEND": "django_redis.cache.RedisCache",
        "LOCATION": "redis://:tjredis139@localhost:16379/3",
        "OPTIONS": {
            "CLIENT_CLASS": "django_redis.client.DefaultClient",
            "CONNECTION_POOL_KWARGS": {"max_connections": 100}            
        }
    }
}
SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
SESSION_CACHE_ALIAS = 'default'
SESSION_COOKIE_AGE = 60 * 5    #设置5分钟过期
'''

