furmeet_events/webproj/settings.py

216 lines
5.3 KiB
Python

"""
Django settings for webproj project.
Generated by 'django-admin startproject' using Django 2.0.6.
For more information on this file, see
https://docs.djangoproject.com/en/2.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.0/ref/settings/
"""
from django.utils.translation import gettext_lazy as _
from . import fsconfig
import os
DEVELOPING = os.uname()[1] == 'forest' or fsconfig.DEBUG
SITE_NAME = fsconfig.SITE_NAME
BASE_DIR = fsconfig.BASE_DIR
SECRET_KEY = fsconfig.SECRET_KEY
SHARED_KEY = fsconfig.SHARED_KEY
DEBUG = fsconfig.DEBUG and DEVELOPING
ALLOWED_HOSTS = [
*fsconfig.SITE_DOMAIN,
'localhost',
'127.0.0.1',
]
if DEBUG and DEVELOPING:
ALLOWED_HOSTS = ['*']
if not DEBUG:
SECURE_BROWSER_XSS_FILTER = True
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
SECURE_HSTS_PRELOAD = True
SECURE_HSTS_SECONDS = 31536000
CSRF_TRUSTED_ORIGINS = (
[f"https://{x}" for x in fsconfig.SITE_DOMAIN] +
[f"http://{x}" for x in fsconfig.SITE_DOMAIN]
)
SECURE_CONTENT_TYPE_NOSNIFF = True
CSRF_COOKIE_SECURE = True
SESSION_COOKIE_SECURE = True
X_FRAME_OPTIONS = 'DENY'
SASS_PRECISION = 13
SASS_OUTPUT_STYLE = 'compact'
SASS_PROCESSOR_AUTO_INCLUDE = True
SASS_PROCESSOR_ENABLED = True
SASS_PROCESSOR_INCLUDE_DIRS = [
os.path.join(BASE_DIR, 'static'),
]
# Application definition
SITE_ID = 1
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
INSTALLED_APPS = [
'django.contrib.admin',
# 'registration',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'django_forms_bootstrap',
# 'django_archive',
# 'rosetta',
'ckeditor',
'colorfield',
# 'corsheaders',
'webproj.conventions',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'webproj.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',
# 'django_settings_export.settings_export',
],
},
},
]
TEMPLATES[0]['DIRS'].append(os.path.join(BASE_DIR, 'webproj', 'templates'))
WSGI_APPLICATION = 'webproj.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/2.0/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/2.0/topics/i18n/
LANGUAGES = [(iso, _(lang)) for iso, lang in fsconfig.LANGUAGES]
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/2.0/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'webproj', 'static_source'),
]
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
if DEBUG and DEVELOPING:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
DEFAULT_FROM_EMAIL = SITE_NAME+' <noreply@'+ALLOWED_HOSTS[0]+'>'
RANGE_1_UNTIL_13 = range(1, 13)
SETTINGS_EXPORT = [
'SITE_NAME',
'RANGE_1_UNTIL_13',
'DEBUG',
]
STATICFILES_FINDERS = [
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'sass_processor.finders.CssFinder',
]
REST_FRAMEWORK = {
'DEFAULT_RENDERER_CLASSES': (
'rest_framework.renderers.JSONRenderer',
'rest_framework.renderers.BrowsableAPIRenderer',
)
}
ROSETTA_WSGI_AUTO_RELOAD = True
ACCOUNT_ACTIVATION_DAYS = 7
REGISTRATION_DEFAULT_FROM_EMAIL = SITE_NAME + \
' Registration <registration@'+fsconfig.SITE_DOMAIN[0]+'>'
REGISTRATION_EMAIL_HTML = True
REGISTRATION_AUTO_LOGIN = True
REGISTRATION_OPEN = fsconfig.REGISTRATION_OPEN
CORS_URLS_REGEX = r'^/api/.*$'
CORS_ORIGIN_ALLOW_ALL = True
IGNORE_ALL_CHOICE_COLLECTION = False
exec('from server_secrets.extraconfig import *')