dpaste/dpaste/settings/base.py

177 lines
5 KiB
Python
Raw Normal View History

# Import global settings to make it easier to extend settings.
from django.conf.global_settings import *
#==============================================================================
# Calculation of directories relative to the module location
#==============================================================================
import os
import sys
import dpaste
PROJECT_DIR, PROJECT_MODULE_NAME = os.path.split(
os.path.dirname(os.path.realpath(dpaste.__file__))
)
PYTHON_BIN = os.path.dirname(sys.executable)
2017-12-13 08:27:17 +11:00
if os.path.exists(os.path.join(PYTHON_BIN, 'activate_this.py')):
# Assume that the presence of 'activate_this.py' in the python bin/
# directory means that we're running in a virtual environment. Set the
# variable root to $VIRTUALENV/var.
VAR_ROOT = os.path.join(os.path.dirname(PYTHON_BIN), 'var')
if not os.path.exists(VAR_ROOT):
os.mkdir(VAR_ROOT)
else:
# Set the variable root to the local configuration location (which is
# ignored by the repository).
VAR_ROOT = os.path.join(PROJECT_DIR, PROJECT_MODULE_NAME, 'conf', 'local')
#==============================================================================
# Generic Django project settings
#==============================================================================
DEBUG = False
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
TIME_ZONE = 'UTC'
SITE_ID = 1
# Make this unique, and don't share it with anybody.
SECRET_KEY = ''
2018-03-12 21:59:38 +11:00
ALLOWED_HOSTS = ['*']
#==============================================================================
# I18N
#==============================================================================
USE_I18N = True
USE_L10N = False
LANGUAGE_CODE = 'en'
LANGUAGES = (
('en', 'English'),
2018-03-24 18:56:38 +11:00
# ('de', 'German'),
# ('es', 'Spanish'),
# ('pt-br', 'Portugese (Brasil)'),
# ('fr', 'French'),
)
LOCALE_PATHS = (
os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'locale')),
)
#==============================================================================
2018-01-08 03:20:59 +11:00
# Project URLS and media settings
#==============================================================================
2018-03-24 18:56:38 +11:00
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'
STATICFILES_DIRS = (
os.path.join(PROJECT_DIR, 'build'),
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
STATIC_ROOT = os.path.join(VAR_ROOT, 'static')
STATIC_URL = '/static/'
ADMIN_MEDIA_PREFIX = '/static/admin/'
ROOT_URLCONF = 'dpaste.urls'
LOGIN_URL = '/accounts/login/'
LOGOUT_URL = '/accounts/logout/'
LOGIN_REDIRECT_URL = '/'
#==============================================================================
# Templates
#==============================================================================
2018-03-12 21:59:38 +11:00
MIDDLEWARE = [
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
2018-01-08 03:20:59 +11:00
'django.middleware.security.SecurityMiddleware',
'csp.middleware.CSPMiddleware',
]
2016-03-24 00:02:19 +11:00
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.template.context_processors.i18n',
2016-03-24 00:02:19 +11:00
],
},
},
]
INSTALLED_APPS = (
'django.contrib.staticfiles',
'django.contrib.sessions',
2018-03-12 21:59:38 +11:00
'dpaste.apps.dpasteAppConfig',
)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'dev.db',
'USER': '',
'PASSWORD': '',
}
}
#==============================================================================
# App specific settings
#==============================================================================
# How many recent snippets to save for every user? IDs of this snippets are
# stored in the user session.
MAX_SNIPPETS_PER_USER = 25
2018-01-08 22:21:52 +11:00
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
SECURE_BROWSER_XSS_FILTER =True
SECURE_CONTENT_TYPE_NOSNIFF = True
CSP_DEFAULT_SRC = ("'none'",)
CSP_SCRIPT_SRC = ("'self'", "'unsafe-inline'")
CSP_STYLE_SRC = ("'self'", "'unsafe-inline'")
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}