lib.itmens/boofilsic/settings.py

216 lines
5.7 KiB
Python
Raw Normal View History

2020-05-01 22:46:15 +08:00
"""
Django settings for boofilsic project.
Generated by 'django-admin startproject' using Django 3.0.5.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.0/ref/settings/
"""
import os
import psycopg2.extensions
# 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/3.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '***REMOVED***'
# 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',
'markdownx',
'users.apps.UsersConfig',
'common.apps.CommonConfig',
'books.apps.BooksConfig',
]
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',
]
ROOT_URLCONF = 'boofilsic.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 = 'boofilsic.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
if DEBUG:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'test',
'USER': 'donotban',
'PASSWORD': 'donotbansilvousplait',
2020-07-29 23:34:06 +08:00
'HOST': '172.18.47.7',
2020-05-01 22:46:15 +08:00
'OPTIONS': {
'client_encoding': 'UTF8',
# 'isolation_level': psycopg2.extensions.ISOLATION_LEVEL_DEFAULT,
}
}
}
else:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'boofilsic',
'USER': 'doubaniux',
'PASSWORD': 'password',
'HOST': 'localhost',
'OPTIONS': {
'client_encoding': 'UTF8',
# 'isolation_level': psycopg2.extensions.ISOLATION_LEVEL_DEFAULT,
}
}
}
# Customized auth backend, glue OAuth2 and Django User model together
# https://docs.djangoproject.com/en/3.0/topics/auth/customizing/#authentication-backends
AUTHENTICATION_BACKENDS = [
2020-05-05 23:50:48 +08:00
'common.mastodon.auth.OAuth2Backend',
2020-05-11 19:16:56 +08:00
]
2020-05-01 22:46:15 +08:00
# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/
LANGUAGE_CODE = 'zh-hans'
TIME_ZONE = 'Asia/Shanghai'
USE_I18N = True
USE_L10N = True
USE_TZ = True
2020-05-06 19:44:44 +08:00
if not DEBUG:
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
SECURE_SSL_REDIRECT = True
2020-05-11 19:19:48 +08:00
SECURE_HSTS_PRELOAD = True
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
SECURE_HSTS_SECONDS = 31536000
2020-05-06 19:44:44 +08:00
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
2020-05-07 06:05:09 +08:00
'formatters': {
'simple': {
'format': '{levelname} {asctime} {module} {message}',
'style': '{',
},
},
2020-05-06 19:44:44 +08:00
'handlers': {
'file': {
'level': 'INFO',
'class': 'logging.FileHandler',
2020-05-06 23:59:57 +08:00
'filename': os.path.join(BASE_DIR, 'log'),
2020-05-07 06:05:09 +08:00
'formatter': 'simple'
2020-05-06 19:44:44 +08:00
},
},
'loggers': {
'django': {
'handlers': ['file'],
'level': 'INFO',
'propagate': True,
},
},
}
2020-05-01 22:46:15 +08:00
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/
STATIC_URL = '/static/'
2020-05-06 20:31:37 +08:00
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
2020-05-01 22:46:15 +08:00
AUTH_USER_MODEL = 'users.User'
MEDIA_URL = '/media/'
2020-05-06 20:31:37 +08:00
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
2020-05-01 22:46:15 +08:00
2020-07-03 15:36:23 +08:00
CLIENT_ID = 'kEbwT9Je5HHg4FoLx4nb0tNaIrPNs5Mw6AYlQlsj2_4'
CLIENT_SECRET = 'xwmEvlmudLCkBmvdzGf8m41Ug5o5di9xnDqeVLrcKSg'
2020-05-01 22:46:15 +08:00
# Path to save report related images, ends without slash
REPORT_MEDIA_PATH_ROOT = 'report/'
MARKDOWNX_MEDIA_PATH = 'review/'
BOOK_MEDIA_PATH_ROOT = 'book/'
2020-05-07 06:05:09 +08:00
DEFAULT_BOOK_IMAGE = os.path.join(BOOK_MEDIA_PATH_ROOT, 'default.svg')
2020-05-01 22:46:15 +08:00
# Mastodon domain name
2020-05-07 01:10:08 +08:00
MASTODON_DOMAIN_NAME = 'donotban.com'
2020-05-01 22:46:15 +08:00
2020-05-05 23:50:48 +08:00
# Timeout of requests to Mastodon, in seconds
MASTODON_TIMEOUT = 30
2020-07-29 23:34:06 +08:00
# Tags for toots posted from this site
MASTODON_TAGS = '#NiceDB #NiceDB%(category)s #NiceDB%(category)s%(type)s'
2020-05-06 16:42:18 +08:00
# Emoji code in mastodon
2020-05-07 06:01:22 +08:00
STAR_SOLID = ':star_solid:'
STAR_HALF = ':star_half:'
STAR_EMPTY = ':star_empty:'
2020-05-06 16:42:18 +08:00
2020-05-01 22:46:15 +08:00
# Default password for each user. since assword is not used any way,
# any string that is not empty is ok
2020-05-07 06:05:09 +08:00
DEFAULT_PASSWORD = '***REMOVED***'
2020-05-01 22:46:15 +08:00
# Default redirect loaction when access login required view
LOGIN_URL = '/users/login/'
# Admin site root url
2020-05-07 06:05:09 +08:00
ADMIN_URL = 'lpLuTqX72Bt2hLfxxRYKeTZdE59Y2hLfpLuTqX72Btx9sXuljYK4tYEmjrHd'
2020-05-01 22:46:15 +08:00
2020-07-03 15:36:23 +08:00
# Luminati proxy settings
LUMINATI_USERNAME = '***REMOVED***'
LUMINATI_PASSWORD = '***REMOVED***'
2020-05-01 22:46:15 +08:00
# https://django-debug-toolbar.readthedocs.io/en/latest/
2020-05-06 19:44:44 +08:00
# maybe benchmarking before deployment