OpenDroneMap-WebODM/webodm/settings.py

245 wiersze
6.2 KiB
Python
Czysty Zwykły widok Historia

2016-08-10 20:23:17 +00:00
"""
Django settings for webodm 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, sys
import datetime
from django.contrib.messages import constants as messages
2016-08-10 20:23:17 +00:00
# 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 = 'gmarsutd!fee6_58=6k)2je#o2^&&)ovu1svjg8k^(a!7qa7r&'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
INTERNAL_IPS = ['127.0.0.1']
2016-08-10 20:23:17 +00:00
ALLOWED_HOSTS = ['*']
2016-08-10 20:23:17 +00:00
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
2016-11-07 17:10:01 +00:00
'django.contrib.gis',
'guardian',
2016-09-30 19:07:09 +00:00
'rest_framework',
'rest_framework_nested',
2016-11-16 20:37:35 +00:00
'rest_framework_swagger',
2016-10-08 16:35:22 +00:00
'webpack_loader',
# 'debug_toolbar',
2016-08-10 20:23:17 +00:00
'app',
2016-09-30 19:07:09 +00:00
'nodeodm',
2016-08-10 20:23:17 +00:00
]
MIDDLEWARE = [
# 'debug_toolbar.middleware.DebugToolbarMiddleware',
2016-08-10 20:23:17 +00:00
'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',
'django.middleware.locale.LocaleMiddleware',
]
ROOT_URLCONF = 'webodm.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(BASE_DIR, 'app', 'templates'),
os.path.join(BASE_DIR, 'app', 'templates', 'app'),
],
'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 = 'webodm.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
DATABASES = {
'default': {
2016-11-07 17:10:01 +00:00
'ENGINE': 'django.contrib.gis.db.backends.postgis',
2016-08-10 20:23:17 +00:00
'NAME': 'webodm_dev',
'USER': 'postgres',
'PASSWORD': 'postgres',
2016-09-11 23:52:31 +00:00
'HOST': 'db',
2016-08-10 20:23:17 +00:00
'PORT': '5432',
}
}
# 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',
},
]
# Hook guardian
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend', # this is default
'guardian.backends.ObjectPermissionBackend',
)
2016-08-10 20:23:17 +00:00
# Internationalization
# https://docs.djangoproject.com/en/1.10/topics/i18n/
LANGUAGE_CODE = 'en-us'
2016-09-29 19:57:24 +00:00
TIME_ZONE = None # Use local server time
2016-08-10 20:23:17 +00:00
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.10/howto/static-files/
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'app', 'static'),
]
2016-10-08 16:35:22 +00:00
# Webpack
WEBPACK_LOADER = {
'DEFAULT': {
'BUNDLE_DIR_NAME': 'app/bundles/',
'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats.json'),
}
}
# Logging
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
},
'simple': {
'format': '%(levelname)s %(message)s'
},
},
'filters': {
'require_debug_true': {
'()': 'django.utils.log.RequireDebugTrue',
},
},
'handlers': {
'console': {
'level': 'INFO',
# 'filters': ['require_debug_true'],
'class': 'logging.StreamHandler',
'formatter': 'simple'
}
},
'loggers': {
'django': {
'handlers': ['console'],
'propagate': True,
'level': 'WARNING',
},
'app.logger': {
'handlers': ['console'],
'level': 'INFO',
},
'apscheduler.executors.default': {
'handlers': ['console'],
'level': 'WARNING',
}
}
}
2016-08-10 20:23:17 +00:00
# Auth
LOGIN_REDIRECT_URL = '/dashboard/'
2016-09-10 15:24:16 +00:00
LOGIN_URL = '/login/'
# File uploads
MEDIA_ROOT = os.path.join(BASE_DIR, 'app', 'media')
# Store flash messages in cookies
MESSAGE_STORAGE = 'django.contrib.messages.storage.cookie.CookieStorage'
MESSAGE_TAGS = {
messages.ERROR: 'danger' # Bootstrap 3 compatibility
}
2016-09-30 19:07:09 +00:00
# REST setup
# Use Django's standard django.contrib.auth permissions (no anonymous usage)
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': [
'app.permissions.GuardianObjectPermissions',
],
'DEFAULT_FILTER_BACKENDS': [
'rest_framework.filters.DjangoObjectPermissionsFilter',
'rest_framework.filters.DjangoFilterBackend',
'rest_framework.filters.OrderingFilter',
2016-09-30 19:07:09 +00:00
],
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.BasicAuthentication',
'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
),
2016-09-30 19:07:09 +00:00
'PAGE_SIZE': 10,
}
JWT_AUTH = {
'JWT_EXPIRATION_DELTA': datetime.timedelta(hours=6),
}
TESTING = sys.argv[1:2] == ['test']
if TESTING:
MEDIA_ROOT = os.path.join(BASE_DIR, 'app', 'media_test')
try:
from .local_settings import *
except ImportError:
pass