188 lines
4.8 KiB
Python
188 lines
4.8 KiB
Python
"""
|
|
Django settings for emblemapi project.
|
|
|
|
Generated by 'django-admin startproject' using Django 3.2.10.
|
|
|
|
For more information on this file, see
|
|
https://docs.djangoproject.com/en/3.2/topics/settings/
|
|
|
|
For the full list of settings and their values, see
|
|
https://docs.djangoproject.com/en/3.2/ref/settings/
|
|
"""
|
|
|
|
import os
|
|
from keys import *
|
|
from pathlib import Path
|
|
|
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
|
|
|
|
# Quick-start development settings - unsuitable for production
|
|
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
|
|
|
|
# SECURITY WARNING: keep the secret key used in production secret!
|
|
SECRET_KEY = 'django-insecure-po^713agbnee6w8&ovj-9@)cyv&-&1q&v8%88(e3o)okn%de_3'
|
|
|
|
# SECURITY WARNING: don't run with debug turned on in production!
|
|
ENV = os.environ.get("EMBLEM_ENV", "debug")
|
|
|
|
DEBUG = ENV in ["debug", "dev"]
|
|
|
|
ALLOWED_HOSTS = ['*']
|
|
|
|
|
|
# Application definition
|
|
|
|
INSTALLED_APPS = [
|
|
'django.contrib.admin',
|
|
'django.contrib.auth',
|
|
'django.contrib.contenttypes',
|
|
'django.contrib.sessions',
|
|
'django.contrib.messages',
|
|
'django.contrib.staticfiles',
|
|
'corsheaders',
|
|
'tastypie',
|
|
'products',
|
|
]
|
|
|
|
MIDDLEWARE = [
|
|
'django.middleware.security.SecurityMiddleware',
|
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
'corsheaders.middleware.CorsMiddleware',
|
|
'django.middleware.common.CommonMiddleware',
|
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
|
'django.contrib.messages.middleware.MessageMiddleware',
|
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
]
|
|
|
|
CORS_ALLOW_ALL_ORIGINS = True
|
|
|
|
ROOT_URLCONF = 'emblemapi.urls'
|
|
|
|
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 = 'emblemapi.wsgi.application'
|
|
|
|
APPEND_SLASH = False
|
|
|
|
# Database
|
|
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
|
|
|
|
if os.environ.get("EMBLEM_DB_TYPE") == "postgres":
|
|
DATABASES = {
|
|
'default': {
|
|
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
|
'NAME': 'emblem',
|
|
'USER': 'emblem',
|
|
'PASSWORD': 'emblempass',
|
|
'HOST': os.environ["EMBLEM_DB_HOST"],
|
|
'PORT': '5432',
|
|
},
|
|
}
|
|
else:
|
|
DATABASES = {
|
|
'default': {
|
|
'ENGINE': 'django.db.backends.sqlite3',
|
|
'NAME': BASE_DIR / 'db.sqlite3',
|
|
},
|
|
}
|
|
|
|
CACHES = {
|
|
'default': {
|
|
'BACKEND': 'django.core.cache.backends.db.DatabaseCache',
|
|
'LOCATION': 'emblem_cache_table',
|
|
}
|
|
}
|
|
|
|
|
|
# Password validation
|
|
# https://docs.djangoproject.com/en/3.2/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/3.2/topics/i18n/
|
|
|
|
LANGUAGE_CODE = 'en-us'
|
|
|
|
TIME_ZONE = 'UTC'
|
|
|
|
USE_I18N = True
|
|
|
|
USE_L10N = True
|
|
|
|
USE_TZ = True
|
|
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
# https://docs.djangoproject.com/en/3.2/howto/static-files/
|
|
|
|
STATIC_URL = '/api/static/'
|
|
STATIC_ROOT = './static'
|
|
|
|
# Default primary key field type
|
|
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
|
|
|
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
|
|
|
DATA_UPLOAD_MAX_MEMORY_SIZE = 20 << 20
|
|
|
|
if ENV == "prod":
|
|
OSS = aliyun_prod_key
|
|
FEATURES_BUCKET = "emblem-features-prod"
|
|
ARCHIVE_BUCKET = "emblem-archive-prod"
|
|
FRAMES_BUCKET = "emblem-frames-prod"
|
|
OSS_QRS_BUCKET = "emblem-qrs"
|
|
OSS_QRS_ENDPOINT = "https://oss-cn-guangzhou.aliyuncs.com"
|
|
else:
|
|
OSS = aliyun_dev_key
|
|
FEATURES_BUCKET = "emblem-features-dev-1"
|
|
ARCHIVE_BUCKET = "emblem-oss-archive-dev-1"
|
|
FRAMES_BUCKET = "emblem-frames-dev"
|
|
OSS_QRS_BUCKET = ARCHIVE_BUCKET
|
|
OSS_QRS_ENDPOINT = None
|
|
|
|
IPINFO_TOKEN = '537dea9ec5c99a'
|
|
|
|
TOKEN_EXPIRE_MINUTES = 180
|
|
|
|
ADMINS = [('Fam Zheng', 'fam@euphon.net')]
|
|
|
|
EMAIL_HOST = 'smtpdm.aliyun.com'
|
|
EMAIL_PORT = 465
|
|
EMAIL_USE_SSL = True
|
|
EMAIL_HOST_USER = 'noreply@emblem-notify.euphon.net'
|
|
EMAIL_HOST_PASSWORD = 'N72yBNi4cJw'
|
|
SERVER_EMAIL = EMAIL_HOST_USER
|
|
|
|
CSRF_TRUSTED_ORIGINS = ['https://*.themblem.com', 'https://themblem.com']
|