"""
Django settings for gated_launch_backend project.

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

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

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

import os
import sys

# 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/1.10/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'htb#ig((*jchh&zqb4+_%rbbc@(8^!roypjbb0f)g3b*dljj&s'

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

ALLOWED_HOSTS = []

BENCHMARK_SETTINGS = 'benchmark_django_rest_framework.benchmark_settings'

# Application definition
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rest_framework',
    'rest_framework.authtoken',
    'mptt',
    'gunicorn',

    'apps.task_manager',
    'apps.common',
    'apps.user_group',
    'apps.auth',
    'apps.app',
    'apps.award',
    'apps.issue',
    'apps.info',
    'apps.strategy',
    'apps.bp',
    'apps.utils',
    'apps.chart',
    'apps.usage',

    BENCHMARK_SETTINGS,
]

AUTH_USER_MODEL = 'gated_launch_auth.User'

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'apps.usage.middlewares.RecordUsageMiddleware',
    'apps.common.middlewares.ResponseFormatMiddleware',
    'django.middleware.common.CommonMiddleware',
    # now in production we use token authentication and
    # front end and back end will be deployed in different sites.
    # Not sure if this middleware is needed.
    # 'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'gated_launch_backend.urls'

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'apps.auth.authentication.ExpiringTokenAuthentication',
        'rest_framework.authentication.SessionAuthentication',
    ),

    'DEFAULT_FILTER_BACKENDS': ('rest_framework.filters.DjangoFilterBackend',),

    'DEFAULT_RENDERER_CLASSES': (
        'rest_framework.renderers.JSONRenderer',
    ),
    'EXCEPTION_HANDLER': 'apps.common.handlers.exception_handler',
    'DEFAULT_PAGINATION_CLASS': 'apps.common.pagination.GatedLaunchPagination',
}

TOKEN_EXPIRATION_SECS = 3600 * 24 * 30

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        '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 = 'gated_launch_backend.wsgi.application'

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

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

from celery.schedules import crontab

CELERY_ENABLE_UTC = True
CELERY_TIMEZONE = 'Asia/Shanghai'
CELERY_BROKER_URL = 'redis://localhost:6379/0'
CELERY_RESULT_BACKEND = 'redis://localhost:6379/0'
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
APP_OWNER_CACHE_MINUTES = 2

CELERY_BEAT_SCHEDULE = {
    'sync_user_db': {
        'task': 'apps.common.tasks.sync_user_info',
        'schedule': crontab(minute=0, hour='*/4'),
    },
    'update_version_download': {
        'task': 'apps.common.tasks.update_version_download_number',
        'schedule': crontab(minute='*/5'),
    },
    'graytask_remind': {
        'task': 'apps.common.tasks.graytask_remind_task',
        'schedule': crontab(minute=0, hour=12, day_of_month='*'),
    },
    'update_jira_to_zc': {
        'task': 'apps.common.tasks.update_jira_to_zc_task',
        'schedule': crontab(minute=30, hour='*'),
    },
    # hope could avoid busy time
    'cache_issues_detailed_info': {
        'task': 'apps.common.tasks.cache_issues_detailed_info',
        'schedule': crontab(minute=0, hour='*/4, 0, 1, 2, 3, 5, 6, 7, 9, 21, 22, 23'),
    },
    # cache app owners
    'cache_issues_app_owners': {
        'task': 'apps.common.tasks.cache_app_owners_task',
        'schedule': crontab(minute='*/{}'.format(APP_OWNER_CACHE_MINUTES)),
    }
    ,
    # auto close issue that should be verified ten days ago
    'auto_close_issue': {
        'task': 'apps.common.tasks.auto_close_issue_task',
        'schedule': crontab(minute=0, hour=7, day_of_month='*'),
    },
    # delete issues from statplat when it's deleted in zhongce and not deleted in statplat yet
    'delete_issues_from_statplat': {
        'task': 'apps.common.tasks.delete_issues_from_statplat_task',
        'schedule': crontab(hour='*'),
    }
    ,
    # auto check the status of issue is consistent with the status of jira
    'auto_check_issue_status_with_jira': {
        'task': 'apps.common.tasks.auto_check_issue_status_with_jira',
        'schedule': crontab(minute=0, hour=3),
    }
}

# Django cache settings
USE_CACHE = True

CACHE_PREFIX = "gated_launch"

VERSION = 1

CACHES = {
    "default": {
        "BACKEND": "django_redis.cache.RedisCache",
        "LOCATION": 'redis://127.0.0.1:6379/1',
        'TIMEOUT': 3600 * 24,
        "OPTIONS": {
            "CLIENT_CLASS": "django_redis.client.DefaultClient"
        },
        "KEY_PREFIX": CACHE_PREFIX,
        'VERSION': VERSION
    }
}

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

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'Asia/Shanghai'

USE_I18N = True

USE_L10N = True

USE_TZ = False

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

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

SWAGGER_SETTINGS = {
    'SECURITY_DEFINITIONS': {
        # 'basic': {
        #     'type': 'basic'
        # },
        "api_key": {

            "type": "apiKey",

            "name": "token",

            "in": "header"

        }
    },
    "VALIDATOR_URL": None
}

FFAN_STAFF_QUERY_URL = "http://beidou.sit.ffan.biz/ffanstaff?select_related=depts"

COMPANY_EMAIL_SUFFIX = "@wanda.cn"

# 其他外部平台的 url
OTHER_PLATFORM_URLS = {
    'APPHUB_APPS': 'http://apphub.ffan.com/api/zhongceapps',
    'SMS': 'http://api.sit.ffan.com/msgcenter/v1/smsOutboxes',
}

EMAIL_SERVER = 'mail.wanda.com.cn'
EMAIL_USERNAME = 'zhongce@wanda.com.cn'
EMAIL_PASSWORD = '4yb1hx98'

# logging 模块
LOG_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../logs")

if not os.path.exists(LOG_PATH):
    os.makedirs(LOG_PATH)

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'standard': {
            'format': '%(asctime)-12s [%(filename)-12s:%(lineno)3d][%(threadName)-12s][%(name)-8s]%(levelname)s %(message)s'
        }
    },
    'filters': {},
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'class': 'django.utils.log.AdminEmailHandler',
            'include_html': True
        },
        'logfile': {
            'level': 'DEBUG',
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': os.path.join(LOG_PATH, "gated.log"),
            'maxBytes': 1024 * 1024 * 5,
            'backupCount': 5,
            'formatter': 'standard'
        },
        'access_logfile': {
            'level': 'INFO',
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': os.path.join(LOG_PATH, "access.log"),
            'maxBytes': 1024 * 1024 * 20,
            'backupCount': 5,
            'formatter': 'standard'
        },
        'django_logfile': {
            'level': 'INFO',
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': os.path.join(LOG_PATH, "django.log"),
            'maxBytes': 1024 * 1024 * 5,
            'backupCount': 5,
            'formatter': 'standard'
        },
        'errorlog': {
            'level': 'ERROR',
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': os.path.join(LOG_PATH, "gated.err"),
            'maxBytes': 1024 * 1024 * 5,
            'backupCount': 5,
            'formatter': 'standard'
        },
        'django_errorlog': {
            'level': 'ERROR',
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': os.path.join(LOG_PATH, "django.err"),
            'maxBytes': 1024 * 1024 * 5,
            'backupCount': 5,
            'formatter': 'standard'
        },
        'console': {
            'level': 'DEBUG',
            'class': 'logging.StreamHandler',
            'formatter': 'standard',
            'stream': sys.stdout,
        }
    },
    'loggers': {
        'django.db.backends': {
            'handlers': ['console'],
            'propagate': True,
            'level': 'DEBUG',
        },
        'debug': {
            'handlers': ['logfile', 'errorlog', 'console'],
            'level': 'DEBUG',
            'propagate': True
        },
        'django': {
            'handlers': ['django_logfile', 'django_errorlog', 'console'],
            'level': 'INFO',
            'propagate': True,
        },
        'access': {
            'handlers': ['access_logfile'],
            'level': 'INFO',
            'propagate': False,
        }
    }
}

FILE_UPLOAD_MAX_MEMORY_SIZE = 5 * 1024 * 1024

INTERNAL_SERVER_ERROR_RESPONSE = {
    'detail': 'The server encountered an internal error or misconfiguration and was unable to complete your request.'
}

BACKEND_ACCESS_LOG_PREFIX = 'backend_access_log:'

TURN_ON_STRATEGY_SMS_AND_EMAIL = False

# weixin related settings
WEIXIN_API_URL = 'https://api.weixin.qq.com/sns/jscode2session'

WEIXIN_APP_ID = 'wx182ac3cf3f27bf8c'

WEIXIN_APP_SECRET = 'e98fc8674794ca6158356aea88dd0d8e'

WEIXIN_AUTH_TOKEN_API_URL = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={}&secret={}'.\
    format(WEIXIN_APP_ID, WEIXIN_APP_SECRET)

WEIXIN_NOTIFICATION_URL = 'https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token={}'

WEIXIN_REPORT_SOURCE_FLAG = '四大区运营'

KE_SU_TONG = 'kst'

# ZC to jira related settings
JIRA_BROWSE_URL = 'http://10.213.120.109:10080/browse/{}'
JIRA_ZC_USER = 'zhongce'
JIRA_STATUS = 'http://10.213.45.106:10080/api/v1/CcStatus/'
JIRA_API_URL = 'http://10.213.45.106:10080/api/v1/CcJira/'
JIRA_UPDATE_LIST = 'http://10.213.45.106:10080/api/v1/CcupdateList/'
IMAGES_URL = 'http://timg.ffan.com/convert/resize/tfs/width_0/height_0/url_{}'
ZC_REPORT_SOURCE = '灰度内测'
ZC_SCORE_TO_JIRA_SEVERITY = {0: '次要', 1: '次要', 2: '次要', 3: '一般', 4: '严重', 5: '非常严重',
                             '0': '次要', '1': '次要', '2': '次要', '3': '一般', '4': '严重', '5': '非常严重'}
JIRA_SEVERITY_TO_ZC_SCORE = {'非常严重': 5, '严重': 4, '一般': 3, '次要': 2}

# rtx setting
RTX_VERIFY_HOST = 'http://develop.ffan.com/rtx_verify'

# switch for send email and bp url
SEND_EMAIL = 'True'
BP_HOST = 'http://zhongce.sit.ffan.com/static/bpplat/#/first'

# 灰度任务前端相关页面地址
TASK_DETAIL_PAGE = '/static/userplatnew/#/mydetail/{app_id}/{task_id}'
TASK_FILE_ISSUE_PAGE = '/static/userplatnew/#/tickling/{app_id}/{task_id}'

# 是否使用sentry
USE_SENTRY = True
SENTRY_CLIENT = 'http://9cae648359544059893025ba0195cb47:53346f73506a41cab4205ca0ab80b415@10.213.42.240:10083/2'

# statplat related settings
STATPLAT_API_URL = 'http://statplat-test.intra.sit.ffan.com/api/v1/'
STATPLAT_TOKEN = '8ebff42f5e1de1943f239ecf3d2524b22c23010c'

# 是否检查issue状态并且发邮件告警
CHECK_ISSUE_STATUS = False
ADMIN_EMAILS = ("wangna67@wanda.cn", "chengyu21@wanda.cn", "pengjinxiao@wanda.cn")

# Attempts to import server specific settings.
# Note that all server specific settings should go to 'settings_local.py'
try:
    from .settings_local import *  # noqa
except ImportError:
    pass

if DEBUG:
    INSTALLED_APPS += ['rest_framework_swagger', 'extra_apps.swagger_example', 'django_extensions']

f37c36293e16c841cb2a16203cf71adf1289ba6f
<mask token>

<mask token>
if not os.path.exists(LOG_PATH):
    os.makedirs(LOG_PATH)
<mask token>
try:
    from .settings_local import *
except ImportError:
    pass
if DEBUG:
    INSTALLED_APPS += ['rest_framework_swagger',
        'extra_apps.swagger_example', 'django_extensions']

<mask token>
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = 'htb#ig((*jchh&zqb4+_%rbbc@(8^!roypjbb0f)g3b*dljj&s'
DEBUG = True
ALLOWED_HOSTS = []
BENCHMARK_SETTINGS = 'benchmark_django_rest_framework.benchmark_settings'
INSTALLED_APPS = ['django.contrib.admin', 'django.contrib.auth',
    'django.contrib.contenttypes', 'django.contrib.sessions',
    'django.contrib.messages', 'django.contrib.staticfiles',
    'rest_framework', 'rest_framework.authtoken', 'mptt', 'gunicorn',
    'apps.task_manager', 'apps.common', 'apps.user_group', 'apps.auth',
    'apps.app', 'apps.award', 'apps.issue', 'apps.info', 'apps.strategy',
    'apps.bp', 'apps.utils', 'apps.chart', 'apps.usage', BENCHMARK_SETTINGS]
AUTH_USER_MODEL = 'gated_launch_auth.User'
MIDDLEWARE = ['django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'apps.usage.middlewares.RecordUsageMiddleware',
    'apps.common.middlewares.ResponseFormatMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware']
ROOT_URLCONF = 'gated_launch_backend.urls'
REST_FRAMEWORK = {'DEFAULT_AUTHENTICATION_CLASSES': (
    'apps.auth.authentication.ExpiringTokenAuthentication',
    'rest_framework.authentication.SessionAuthentication'),
    'DEFAULT_FILTER_BACKENDS': (
    'rest_framework.filters.DjangoFilterBackend',),
    'DEFAULT_RENDERER_CLASSES': ('rest_framework.renderers.JSONRenderer',),
    'EXCEPTION_HANDLER': 'apps.common.handlers.exception_handler',
    'DEFAULT_PAGINATION_CLASS': 'apps.common.pagination.GatedLaunchPagination'}
TOKEN_EXPIRATION_SECS = 3600 * 24 * 30
TEMPLATES = [{'BACKEND': 'django.template.backends.django.DjangoTemplates',
    'DIRS': [], '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 = 'gated_launch_backend.wsgi.application'
DATABASES = {'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': os
    .path.join(BASE_DIR, 'db.sqlite3')}}
<mask token>
CELERY_ENABLE_UTC = True
CELERY_TIMEZONE = 'Asia/Shanghai'
CELERY_BROKER_URL = 'redis://localhost:6379/0'
CELERY_RESULT_BACKEND = 'redis://localhost:6379/0'
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
APP_OWNER_CACHE_MINUTES = 2
CELERY_BEAT_SCHEDULE = {'sync_user_db': {'task':
    'apps.common.tasks.sync_user_info', 'schedule': crontab(minute=0, hour=
    '*/4')}, 'update_version_download': {'task':
    'apps.common.tasks.update_version_download_number', 'schedule': crontab
    (minute='*/5')}, 'graytask_remind': {'task':
    'apps.common.tasks.graytask_remind_task', 'schedule': crontab(minute=0,
    hour=12, day_of_month='*')}, 'update_jira_to_zc': {'task':
    'apps.common.tasks.update_jira_to_zc_task', 'schedule': crontab(minute=
    30, hour='*')}, 'cache_issues_detailed_info': {'task':
    'apps.common.tasks.cache_issues_detailed_info', 'schedule': crontab(
    minute=0, hour='*/4, 0, 1, 2, 3, 5, 6, 7, 9, 21, 22, 23')},
    'cache_issues_app_owners': {'task':
    'apps.common.tasks.cache_app_owners_task', 'schedule': crontab(minute=
    '*/{}'.format(APP_OWNER_CACHE_MINUTES))}, 'auto_close_issue': {'task':
    'apps.common.tasks.auto_close_issue_task', 'schedule': crontab(minute=0,
    hour=7, day_of_month='*')}, 'delete_issues_from_statplat': {'task':
    'apps.common.tasks.delete_issues_from_statplat_task', 'schedule':
    crontab(hour='*')}, 'auto_check_issue_status_with_jira': {'task':
    'apps.common.tasks.auto_check_issue_status_with_jira', 'schedule':
    crontab(minute=0, hour=3)}}
USE_CACHE = True
CACHE_PREFIX = 'gated_launch'
VERSION = 1
CACHES = {'default': {'BACKEND': 'django_redis.cache.RedisCache',
    'LOCATION': 'redis://127.0.0.1:6379/1', 'TIMEOUT': 3600 * 24, 'OPTIONS':
    {'CLIENT_CLASS': 'django_redis.client.DefaultClient'}, 'KEY_PREFIX':
    CACHE_PREFIX, 'VERSION': VERSION}}
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'}
    ]
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'Asia/Shanghai'
USE_I18N = True
USE_L10N = True
USE_TZ = False
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
STATICFILES_DIRS = os.path.join(BASE_DIR, 'statics/'),
SWAGGER_SETTINGS = {'SECURITY_DEFINITIONS': {'api_key': {'type': 'apiKey',
    'name': 'token', 'in': 'header'}}, 'VALIDATOR_URL': None}
FFAN_STAFF_QUERY_URL = (
    'http://beidou.sit.ffan.biz/ffanstaff?select_related=depts')
COMPANY_EMAIL_SUFFIX = '@wanda.cn'
OTHER_PLATFORM_URLS = {'APPHUB_APPS':
    'http://apphub.ffan.com/api/zhongceapps', 'SMS':
    'http://api.sit.ffan.com/msgcenter/v1/smsOutboxes'}
EMAIL_SERVER = 'mail.wanda.com.cn'
EMAIL_USERNAME = 'zhongce@wanda.com.cn'
EMAIL_PASSWORD = '4yb1hx98'
LOG_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), '../logs')
if not os.path.exists(LOG_PATH):
    os.makedirs(LOG_PATH)
LOGGING = {'version': 1, 'disable_existing_loggers': False, 'formatters': {
    'standard': {'format':
    '%(asctime)-12s [%(filename)-12s:%(lineno)3d][%(threadName)-12s][%(name)-8s]%(levelname)s %(message)s'
    }}, 'filters': {}, 'handlers': {'mail_admins': {'level': 'ERROR',
    'class': 'django.utils.log.AdminEmailHandler', 'include_html': True},
    'logfile': {'level': 'DEBUG', 'class':
    'logging.handlers.RotatingFileHandler', 'filename': os.path.join(
    LOG_PATH, 'gated.log'), 'maxBytes': 1024 * 1024 * 5, 'backupCount': 5,
    'formatter': 'standard'}, 'access_logfile': {'level': 'INFO', 'class':
    'logging.handlers.RotatingFileHandler', 'filename': os.path.join(
    LOG_PATH, 'access.log'), 'maxBytes': 1024 * 1024 * 20, 'backupCount': 5,
    'formatter': 'standard'}, 'django_logfile': {'level': 'INFO', 'class':
    'logging.handlers.RotatingFileHandler', 'filename': os.path.join(
    LOG_PATH, 'django.log'), 'maxBytes': 1024 * 1024 * 5, 'backupCount': 5,
    'formatter': 'standard'}, 'errorlog': {'level': 'ERROR', 'class':
    'logging.handlers.RotatingFileHandler', 'filename': os.path.join(
    LOG_PATH, 'gated.err'), 'maxBytes': 1024 * 1024 * 5, 'backupCount': 5,
    'formatter': 'standard'}, 'django_errorlog': {'level': 'ERROR', 'class':
    'logging.handlers.RotatingFileHandler', 'filename': os.path.join(
    LOG_PATH, 'django.err'), 'maxBytes': 1024 * 1024 * 5, 'backupCount': 5,
    'formatter': 'standard'}, 'console': {'level': 'DEBUG', 'class':
    'logging.StreamHandler', 'formatter': 'standard', 'stream': sys.stdout}
    }, 'loggers': {'django.db.backends': {'handlers': ['console'],
    'propagate': True, 'level': 'DEBUG'}, 'debug': {'handlers': ['logfile',
    'errorlog', 'console'], 'level': 'DEBUG', 'propagate': True}, 'django':
    {'handlers': ['django_logfile', 'django_errorlog', 'console'], 'level':
    'INFO', 'propagate': True}, 'access': {'handlers': ['access_logfile'],
    'level': 'INFO', 'propagate': False}}}
FILE_UPLOAD_MAX_MEMORY_SIZE = 5 * 1024 * 1024
INTERNAL_SERVER_ERROR_RESPONSE = {'detail':
    'The server encountered an internal error or misconfiguration and was unable to complete your request.'
    }
BACKEND_ACCESS_LOG_PREFIX = 'backend_access_log:'
TURN_ON_STRATEGY_SMS_AND_EMAIL = False
WEIXIN_API_URL = 'https://api.weixin.qq.com/sns/jscode2session'
WEIXIN_APP_ID = 'wx182ac3cf3f27bf8c'
WEIXIN_APP_SECRET = 'e98fc8674794ca6158356aea88dd0d8e'
WEIXIN_AUTH_TOKEN_API_URL = (
    'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={}&secret={}'
    .format(WEIXIN_APP_ID, WEIXIN_APP_SECRET))
WEIXIN_NOTIFICATION_URL = (
    'https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token={}'
    )
WEIXIN_REPORT_SOURCE_FLAG = '四大区运营'
KE_SU_TONG = 'kst'
JIRA_BROWSE_URL = 'http://10.213.120.109:10080/browse/{}'
JIRA_ZC_USER = 'zhongce'
JIRA_STATUS = 'http://10.213.45.106:10080/api/v1/CcStatus/'
JIRA_API_URL = 'http://10.213.45.106:10080/api/v1/CcJira/'
JIRA_UPDATE_LIST = 'http://10.213.45.106:10080/api/v1/CcupdateList/'
IMAGES_URL = 'http://timg.ffan.com/convert/resize/tfs/width_0/height_0/url_{}'
ZC_REPORT_SOURCE = '灰度内测'
ZC_SCORE_TO_JIRA_SEVERITY = {(0): '次要', (1): '次要', (2): '次要', (3): '一般', (4
    ): '严重', (5): '非常严重', '0': '次要', '1': '次要', '2': '次要', '3': '一般', '4':
    '严重', '5': '非常严重'}
JIRA_SEVERITY_TO_ZC_SCORE = {'非常严重': 5, '严重': 4, '一般': 3, '次要': 2}
RTX_VERIFY_HOST = 'http://develop.ffan.com/rtx_verify'
SEND_EMAIL = 'True'
BP_HOST = 'http://zhongce.sit.ffan.com/static/bpplat/#/first'
TASK_DETAIL_PAGE = '/static/userplatnew/#/mydetail/{app_id}/{task_id}'
TASK_FILE_ISSUE_PAGE = '/static/userplatnew/#/tickling/{app_id}/{task_id}'
USE_SENTRY = True
SENTRY_CLIENT = (
    'http://9cae648359544059893025ba0195cb47:53346f73506a41cab4205ca0ab80b415@10.213.42.240:10083/2'
    )
STATPLAT_API_URL = 'http://statplat-test.intra.sit.ffan.com/api/v1/'
STATPLAT_TOKEN = '8ebff42f5e1de1943f239ecf3d2524b22c23010c'
CHECK_ISSUE_STATUS = False
ADMIN_EMAILS = ('wangna67@wanda.cn', 'chengyu21@wanda.cn',
    'pengjinxiao@wanda.cn')
try:
    from .settings_local import *
except ImportError:
    pass
if DEBUG:
    INSTALLED_APPS += ['rest_framework_swagger',
        'extra_apps.swagger_example', 'django_extensions']

<mask token>
import os
import sys
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = 'htb#ig((*jchh&zqb4+_%rbbc@(8^!roypjbb0f)g3b*dljj&s'
DEBUG = True
ALLOWED_HOSTS = []
BENCHMARK_SETTINGS = 'benchmark_django_rest_framework.benchmark_settings'
INSTALLED_APPS = ['django.contrib.admin', 'django.contrib.auth',
    'django.contrib.contenttypes', 'django.contrib.sessions',
    'django.contrib.messages', 'django.contrib.staticfiles',
    'rest_framework', 'rest_framework.authtoken', 'mptt', 'gunicorn',
    'apps.task_manager', 'apps.common', 'apps.user_group', 'apps.auth',
    'apps.app', 'apps.award', 'apps.issue', 'apps.info', 'apps.strategy',
    'apps.bp', 'apps.utils', 'apps.chart', 'apps.usage', BENCHMARK_SETTINGS]
AUTH_USER_MODEL = 'gated_launch_auth.User'
MIDDLEWARE = ['django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'apps.usage.middlewares.RecordUsageMiddleware',
    'apps.common.middlewares.ResponseFormatMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware']
ROOT_URLCONF = 'gated_launch_backend.urls'
REST_FRAMEWORK = {'DEFAULT_AUTHENTICATION_CLASSES': (
    'apps.auth.authentication.ExpiringTokenAuthentication',
    'rest_framework.authentication.SessionAuthentication'),
    'DEFAULT_FILTER_BACKENDS': (
    'rest_framework.filters.DjangoFilterBackend',),
    'DEFAULT_RENDERER_CLASSES': ('rest_framework.renderers.JSONRenderer',),
    'EXCEPTION_HANDLER': 'apps.common.handlers.exception_handler',
    'DEFAULT_PAGINATION_CLASS': 'apps.common.pagination.GatedLaunchPagination'}
TOKEN_EXPIRATION_SECS = 3600 * 24 * 30
TEMPLATES = [{'BACKEND': 'django.template.backends.django.DjangoTemplates',
    'DIRS': [], '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 = 'gated_launch_backend.wsgi.application'
DATABASES = {'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': os
    .path.join(BASE_DIR, 'db.sqlite3')}}
from celery.schedules import crontab
CELERY_ENABLE_UTC = True
CELERY_TIMEZONE = 'Asia/Shanghai'
CELERY_BROKER_URL = 'redis://localhost:6379/0'
CELERY_RESULT_BACKEND = 'redis://localhost:6379/0'
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
APP_OWNER_CACHE_MINUTES = 2
CELERY_BEAT_SCHEDULE = {'sync_user_db': {'task':
    'apps.common.tasks.sync_user_info', 'schedule': crontab(minute=0, hour=
    '*/4')}, 'update_version_download': {'task':
    'apps.common.tasks.update_version_download_number', 'schedule': crontab
    (minute='*/5')}, 'graytask_remind': {'task':
    'apps.common.tasks.graytask_remind_task', 'schedule': crontab(minute=0,
    hour=12, day_of_month='*')}, 'update_jira_to_zc': {'task':
    'apps.common.tasks.update_jira_to_zc_task', 'schedule': crontab(minute=
    30, hour='*')}, 'cache_issues_detailed_info': {'task':
    'apps.common.tasks.cache_issues_detailed_info', 'schedule': crontab(
    minute=0, hour='*/4, 0, 1, 2, 3, 5, 6, 7, 9, 21, 22, 23')},
    'cache_issues_app_owners': {'task':
    'apps.common.tasks.cache_app_owners_task', 'schedule': crontab(minute=
    '*/{}'.format(APP_OWNER_CACHE_MINUTES))}, 'auto_close_issue': {'task':
    'apps.common.tasks.auto_close_issue_task', 'schedule': crontab(minute=0,
    hour=7, day_of_month='*')}, 'delete_issues_from_statplat': {'task':
    'apps.common.tasks.delete_issues_from_statplat_task', 'schedule':
    crontab(hour='*')}, 'auto_check_issue_status_with_jira': {'task':
    'apps.common.tasks.auto_check_issue_status_with_jira', 'schedule':
    crontab(minute=0, hour=3)}}
USE_CACHE = True
CACHE_PREFIX = 'gated_launch'
VERSION = 1
CACHES = {'default': {'BACKEND': 'django_redis.cache.RedisCache',
    'LOCATION': 'redis://127.0.0.1:6379/1', 'TIMEOUT': 3600 * 24, 'OPTIONS':
    {'CLIENT_CLASS': 'django_redis.client.DefaultClient'}, 'KEY_PREFIX':
    CACHE_PREFIX, 'VERSION': VERSION}}
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'}
    ]
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'Asia/Shanghai'
USE_I18N = True
USE_L10N = True
USE_TZ = False
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
STATICFILES_DIRS = os.path.join(BASE_DIR, 'statics/'),
SWAGGER_SETTINGS = {'SECURITY_DEFINITIONS': {'api_key': {'type': 'apiKey',
    'name': 'token', 'in': 'header'}}, 'VALIDATOR_URL': None}
FFAN_STAFF_QUERY_URL = (
    'http://beidou.sit.ffan.biz/ffanstaff?select_related=depts')
COMPANY_EMAIL_SUFFIX = '@wanda.cn'
OTHER_PLATFORM_URLS = {'APPHUB_APPS':
    'http://apphub.ffan.com/api/zhongceapps', 'SMS':
    'http://api.sit.ffan.com/msgcenter/v1/smsOutboxes'}
EMAIL_SERVER = 'mail.wanda.com.cn'
EMAIL_USERNAME = 'zhongce@wanda.com.cn'
EMAIL_PASSWORD = '4yb1hx98'
LOG_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), '../logs')
if not os.path.exists(LOG_PATH):
    os.makedirs(LOG_PATH)
LOGGING = {'version': 1, 'disable_existing_loggers': False, 'formatters': {
    'standard': {'format':
    '%(asctime)-12s [%(filename)-12s:%(lineno)3d][%(threadName)-12s][%(name)-8s]%(levelname)s %(message)s'
    }}, 'filters': {}, 'handlers': {'mail_admins': {'level': 'ERROR',
    'class': 'django.utils.log.AdminEmailHandler', 'include_html': True},
    'logfile': {'level': 'DEBUG', 'class':
    'logging.handlers.RotatingFileHandler', 'filename': os.path.join(
    LOG_PATH, 'gated.log'), 'maxBytes': 1024 * 1024 * 5, 'backupCount': 5,
    'formatter': 'standard'}, 'access_logfile': {'level': 'INFO', 'class':
    'logging.handlers.RotatingFileHandler', 'filename': os.path.join(
    LOG_PATH, 'access.log'), 'maxBytes': 1024 * 1024 * 20, 'backupCount': 5,
    'formatter': 'standard'}, 'django_logfile': {'level': 'INFO', 'class':
    'logging.handlers.RotatingFileHandler', 'filename': os.path.join(
    LOG_PATH, 'django.log'), 'maxBytes': 1024 * 1024 * 5, 'backupCount': 5,
    'formatter': 'standard'}, 'errorlog': {'level': 'ERROR', 'class':
    'logging.handlers.RotatingFileHandler', 'filename': os.path.join(
    LOG_PATH, 'gated.err'), 'maxBytes': 1024 * 1024 * 5, 'backupCount': 5,
    'formatter': 'standard'}, 'django_errorlog': {'level': 'ERROR', 'class':
    'logging.handlers.RotatingFileHandler', 'filename': os.path.join(
    LOG_PATH, 'django.err'), 'maxBytes': 1024 * 1024 * 5, 'backupCount': 5,
    'formatter': 'standard'}, 'console': {'level': 'DEBUG', 'class':
    'logging.StreamHandler', 'formatter': 'standard', 'stream': sys.stdout}
    }, 'loggers': {'django.db.backends': {'handlers': ['console'],
    'propagate': True, 'level': 'DEBUG'}, 'debug': {'handlers': ['logfile',
    'errorlog', 'console'], 'level': 'DEBUG', 'propagate': True}, 'django':
    {'handlers': ['django_logfile', 'django_errorlog', 'console'], 'level':
    'INFO', 'propagate': True}, 'access': {'handlers': ['access_logfile'],
    'level': 'INFO', 'propagate': False}}}
FILE_UPLOAD_MAX_MEMORY_SIZE = 5 * 1024 * 1024
INTERNAL_SERVER_ERROR_RESPONSE = {'detail':
    'The server encountered an internal error or misconfiguration and was unable to complete your request.'
    }
BACKEND_ACCESS_LOG_PREFIX = 'backend_access_log:'
TURN_ON_STRATEGY_SMS_AND_EMAIL = False
WEIXIN_API_URL = 'https://api.weixin.qq.com/sns/jscode2session'
WEIXIN_APP_ID = 'wx182ac3cf3f27bf8c'
WEIXIN_APP_SECRET = 'e98fc8674794ca6158356aea88dd0d8e'
WEIXIN_AUTH_TOKEN_API_URL = (
    'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={}&secret={}'
    .format(WEIXIN_APP_ID, WEIXIN_APP_SECRET))
WEIXIN_NOTIFICATION_URL = (
    'https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token={}'
    )
WEIXIN_REPORT_SOURCE_FLAG = '四大区运营'
KE_SU_TONG = 'kst'
JIRA_BROWSE_URL = 'http://10.213.120.109:10080/browse/{}'
JIRA_ZC_USER = 'zhongce'
JIRA_STATUS = 'http://10.213.45.106:10080/api/v1/CcStatus/'
JIRA_API_URL = 'http://10.213.45.106:10080/api/v1/CcJira/'
JIRA_UPDATE_LIST = 'http://10.213.45.106:10080/api/v1/CcupdateList/'
IMAGES_URL = 'http://timg.ffan.com/convert/resize/tfs/width_0/height_0/url_{}'
ZC_REPORT_SOURCE = '灰度内测'
ZC_SCORE_TO_JIRA_SEVERITY = {(0): '次要', (1): '次要', (2): '次要', (3): '一般', (4
    ): '严重', (5): '非常严重', '0': '次要', '1': '次要', '2': '次要', '3': '一般', '4':
    '严重', '5': '非常严重'}
JIRA_SEVERITY_TO_ZC_SCORE = {'非常严重': 5, '严重': 4, '一般': 3, '次要': 2}
RTX_VERIFY_HOST = 'http://develop.ffan.com/rtx_verify'
SEND_EMAIL = 'True'
BP_HOST = 'http://zhongce.sit.ffan.com/static/bpplat/#/first'
TASK_DETAIL_PAGE = '/static/userplatnew/#/mydetail/{app_id}/{task_id}'
TASK_FILE_ISSUE_PAGE = '/static/userplatnew/#/tickling/{app_id}/{task_id}'
USE_SENTRY = True
SENTRY_CLIENT = (
    'http://9cae648359544059893025ba0195cb47:53346f73506a41cab4205ca0ab80b415@10.213.42.240:10083/2'
    )
STATPLAT_API_URL = 'http://statplat-test.intra.sit.ffan.com/api/v1/'
STATPLAT_TOKEN = '8ebff42f5e1de1943f239ecf3d2524b22c23010c'
CHECK_ISSUE_STATUS = False
ADMIN_EMAILS = ('wangna67@wanda.cn', 'chengyu21@wanda.cn',
    'pengjinxiao@wanda.cn')
try:
    from .settings_local import *
except ImportError:
    pass
if DEBUG:
    INSTALLED_APPS += ['rest_framework_swagger',
        'extra_apps.swagger_example', 'django_extensions']

"""
Django settings for gated_launch_backend project.

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

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

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

import os
import sys

# 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/1.10/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'htb#ig((*jchh&zqb4+_%rbbc@(8^!roypjbb0f)g3b*dljj&s'

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

ALLOWED_HOSTS = []

BENCHMARK_SETTINGS = 'benchmark_django_rest_framework.benchmark_settings'

# Application definition
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rest_framework',
    'rest_framework.authtoken',
    'mptt',
    'gunicorn',

    'apps.task_manager',
    'apps.common',
    'apps.user_group',
    'apps.auth',
    'apps.app',
    'apps.award',
    'apps.issue',
    'apps.info',
    'apps.strategy',
    'apps.bp',
    'apps.utils',
    'apps.chart',
    'apps.usage',

    BENCHMARK_SETTINGS,
]

AUTH_USER_MODEL = 'gated_launch_auth.User'

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'apps.usage.middlewares.RecordUsageMiddleware',
    'apps.common.middlewares.ResponseFormatMiddleware',
    'django.middleware.common.CommonMiddleware',
    # now in production we use token authentication and
    # front end and back end will be deployed in different sites.
    # Not sure if this middleware is needed.
    # 'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'gated_launch_backend.urls'

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'apps.auth.authentication.ExpiringTokenAuthentication',
        'rest_framework.authentication.SessionAuthentication',
    ),

    'DEFAULT_FILTER_BACKENDS': ('rest_framework.filters.DjangoFilterBackend',),

    'DEFAULT_RENDERER_CLASSES': (
        'rest_framework.renderers.JSONRenderer',
    ),
    'EXCEPTION_HANDLER': 'apps.common.handlers.exception_handler',
    'DEFAULT_PAGINATION_CLASS': 'apps.common.pagination.GatedLaunchPagination',
}

TOKEN_EXPIRATION_SECS = 3600 * 24 * 30

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        '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 = 'gated_launch_backend.wsgi.application'

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

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

from celery.schedules import crontab

CELERY_ENABLE_UTC = True
CELERY_TIMEZONE = 'Asia/Shanghai'
CELERY_BROKER_URL = 'redis://localhost:6379/0'
CELERY_RESULT_BACKEND = 'redis://localhost:6379/0'
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
APP_OWNER_CACHE_MINUTES = 2

CELERY_BEAT_SCHEDULE = {
    'sync_user_db': {
        'task': 'apps.common.tasks.sync_user_info',
        'schedule': crontab(minute=0, hour='*/4'),
    },
    'update_version_download': {
        'task': 'apps.common.tasks.update_version_download_number',
        'schedule': crontab(minute='*/5'),
    },
    'graytask_remind': {
        'task': 'apps.common.tasks.graytask_remind_task',
        'schedule': crontab(minute=0, hour=12, day_of_month='*'),
    },
    'update_jira_to_zc': {
        'task': 'apps.common.tasks.update_jira_to_zc_task',
        'schedule': crontab(minute=30, hour='*'),
    },
    # hope could avoid busy time
    'cache_issues_detailed_info': {
        'task': 'apps.common.tasks.cache_issues_detailed_info',
        'schedule': crontab(minute=0, hour='*/4, 0, 1, 2, 3, 5, 6, 7, 9, 21, 22, 23'),
    },
    # cache app owners
    'cache_issues_app_owners': {
        'task': 'apps.common.tasks.cache_app_owners_task',
        'schedule': crontab(minute='*/{}'.format(APP_OWNER_CACHE_MINUTES)),
    }
    ,
    # auto close issue that should be verified ten days ago
    'auto_close_issue': {
        'task': 'apps.common.tasks.auto_close_issue_task',
        'schedule': crontab(minute=0, hour=7, day_of_month='*'),
    },
    # delete issues from statplat when it's deleted in zhongce and not deleted in statplat yet
    'delete_issues_from_statplat': {
        'task': 'apps.common.tasks.delete_issues_from_statplat_task',
        'schedule': crontab(hour='*'),
    }
    ,
    # auto check the status of issue is consistent with the status of jira
    'auto_check_issue_status_with_jira': {
        'task': 'apps.common.tasks.auto_check_issue_status_with_jira',
        'schedule': crontab(minute=0, hour=3),
    }
}

# Django cache settings
USE_CACHE = True

CACHE_PREFIX = "gated_launch"

VERSION = 1

CACHES = {
    "default": {
        "BACKEND": "django_redis.cache.RedisCache",
        "LOCATION": 'redis://127.0.0.1:6379/1',
        'TIMEOUT': 3600 * 24,
        "OPTIONS": {
            "CLIENT_CLASS": "django_redis.client.DefaultClient"
        },
        "KEY_PREFIX": CACHE_PREFIX,
        'VERSION': VERSION
    }
}

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

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'Asia/Shanghai'

USE_I18N = True

USE_L10N = True

USE_TZ = False

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

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

SWAGGER_SETTINGS = {
    'SECURITY_DEFINITIONS': {
        # 'basic': {
        #     'type': 'basic'
        # },
        "api_key": {

            "type": "apiKey",

            "name": "token",

            "in": "header"

        }
    },
    "VALIDATOR_URL": None
}

FFAN_STAFF_QUERY_URL = "http://beidou.sit.ffan.biz/ffanstaff?select_related=depts"

COMPANY_EMAIL_SUFFIX = "@wanda.cn"

# 其他外部平台的 url
OTHER_PLATFORM_URLS = {
    'APPHUB_APPS': 'http://apphub.ffan.com/api/zhongceapps',
    'SMS': 'http://api.sit.ffan.com/msgcenter/v1/smsOutboxes',
}

EMAIL_SERVER = 'mail.wanda.com.cn'
EMAIL_USERNAME = 'zhongce@wanda.com.cn'
EMAIL_PASSWORD = '4yb1hx98'

# logging 模块
LOG_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../logs")

if not os.path.exists(LOG_PATH):
    os.makedirs(LOG_PATH)

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'standard': {
            'format': '%(asctime)-12s [%(filename)-12s:%(lineno)3d][%(threadName)-12s][%(name)-8s]%(levelname)s %(message)s'
        }
    },
    'filters': {},
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'class': 'django.utils.log.AdminEmailHandler',
            'include_html': True
        },
        'logfile': {
            'level': 'DEBUG',
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': os.path.join(LOG_PATH, "gated.log"),
            'maxBytes': 1024 * 1024 * 5,
            'backupCount': 5,
            'formatter': 'standard'
        },
        'access_logfile': {
            'level': 'INFO',
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': os.path.join(LOG_PATH, "access.log"),
            'maxBytes': 1024 * 1024 * 20,
            'backupCount': 5,
            'formatter': 'standard'
        },
        'django_logfile': {
            'level': 'INFO',
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': os.path.join(LOG_PATH, "django.log"),
            'maxBytes': 1024 * 1024 * 5,
            'backupCount': 5,
            'formatter': 'standard'
        },
        'errorlog': {
            'level': 'ERROR',
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': os.path.join(LOG_PATH, "gated.err"),
            'maxBytes': 1024 * 1024 * 5,
            'backupCount': 5,
            'formatter': 'standard'
        },
        'django_errorlog': {
            'level': 'ERROR',
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': os.path.join(LOG_PATH, "django.err"),
            'maxBytes': 1024 * 1024 * 5,
            'backupCount': 5,
            'formatter': 'standard'
        },
        'console': {
            'level': 'DEBUG',
            'class': 'logging.StreamHandler',
            'formatter': 'standard',
            'stream': sys.stdout,
        }
    },
    'loggers': {
        'django.db.backends': {
            'handlers': ['console'],
            'propagate': True,
            'level': 'DEBUG',
        },
        'debug': {
            'handlers': ['logfile', 'errorlog', 'console'],
            'level': 'DEBUG',
            'propagate': True
        },
        'django': {
            'handlers': ['django_logfile', 'django_errorlog', 'console'],
            'level': 'INFO',
            'propagate': True,
        },
        'access': {
            'handlers': ['access_logfile'],
            'level': 'INFO',
            'propagate': False,
        }
    }
}

FILE_UPLOAD_MAX_MEMORY_SIZE = 5 * 1024 * 1024

INTERNAL_SERVER_ERROR_RESPONSE = {
    'detail': 'The server encountered an internal error or misconfiguration and was unable to complete your request.'
}

BACKEND_ACCESS_LOG_PREFIX = 'backend_access_log:'

TURN_ON_STRATEGY_SMS_AND_EMAIL = False

# weixin related settings
WEIXIN_API_URL = 'https://api.weixin.qq.com/sns/jscode2session'

WEIXIN_APP_ID = 'wx182ac3cf3f27bf8c'

WEIXIN_APP_SECRET = 'e98fc8674794ca6158356aea88dd0d8e'

WEIXIN_AUTH_TOKEN_API_URL = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={}&secret={}'.\
    format(WEIXIN_APP_ID, WEIXIN_APP_SECRET)

WEIXIN_NOTIFICATION_URL = 'https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token={}'

WEIXIN_REPORT_SOURCE_FLAG = '四大区运营'

KE_SU_TONG = 'kst'

# ZC to jira related settings
JIRA_BROWSE_URL = 'http://10.213.120.109:10080/browse/{}'
JIRA_ZC_USER = 'zhongce'
JIRA_STATUS = 'http://10.213.45.106:10080/api/v1/CcStatus/'
JIRA_API_URL = 'http://10.213.45.106:10080/api/v1/CcJira/'
JIRA_UPDATE_LIST = 'http://10.213.45.106:10080/api/v1/CcupdateList/'
IMAGES_URL = 'http://timg.ffan.com/convert/resize/tfs/width_0/height_0/url_{}'
ZC_REPORT_SOURCE = '灰度内测'
ZC_SCORE_TO_JIRA_SEVERITY = {0: '次要', 1: '次要', 2: '次要', 3: '一般', 4: '严重', 5: '非常严重',
                             '0': '次要', '1': '次要', '2': '次要', '3': '一般', '4': '严重', '5': '非常严重'}
JIRA_SEVERITY_TO_ZC_SCORE = {'非常严重': 5, '严重': 4, '一般': 3, '次要': 2}

# rtx setting
RTX_VERIFY_HOST = 'http://develop.ffan.com/rtx_verify'

# switch for send email and bp url
SEND_EMAIL = 'True'
BP_HOST = 'http://zhongce.sit.ffan.com/static/bpplat/#/first'

# 灰度任务前端相关页面地址
TASK_DETAIL_PAGE = '/static/userplatnew/#/mydetail/{app_id}/{task_id}'
TASK_FILE_ISSUE_PAGE = '/static/userplatnew/#/tickling/{app_id}/{task_id}'

# 是否使用sentry
USE_SENTRY = True
SENTRY_CLIENT = 'http://9cae648359544059893025ba0195cb47:53346f73506a41cab4205ca0ab80b415@10.213.42.240:10083/2'

# statplat related settings
STATPLAT_API_URL = 'http://statplat-test.intra.sit.ffan.com/api/v1/'
STATPLAT_TOKEN = '8ebff42f5e1de1943f239ecf3d2524b22c23010c'

# 是否检查issue状态并且发邮件告警
CHECK_ISSUE_STATUS = False
ADMIN_EMAILS = ("wangna67@wanda.cn", "chengyu21@wanda.cn", "pengjinxiao@wanda.cn")

# Attempts to import server specific settings.
# Note that all server specific settings should go to 'settings_local.py'
try:
    from .settings_local import *  # noqa
except ImportError:
    pass

if DEBUG:
    INSTALLED_APPS += ['rest_framework_swagger', 'extra_apps.swagger_example', 'django_extensions']
