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/
|
|
|
|
"""
|
|
|
|
|
2016-10-24 18:14:35 +00:00
|
|
|
import os, sys
|
2017-02-08 19:14:24 +00:00
|
|
|
|
|
|
|
import datetime
|
2016-09-22 22:18:35 +00:00
|
|
|
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
|
2016-11-10 17:26:04 +00:00
|
|
|
INTERNAL_IPS = ['127.0.0.1']
|
2016-08-10 20:23:17 +00:00
|
|
|
|
2017-02-11 15:25:00 +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',
|
2016-10-04 20:36:08 +00:00
|
|
|
'guardian',
|
2016-09-30 19:07:09 +00:00
|
|
|
'rest_framework',
|
2016-10-13 16:21:12 +00:00
|
|
|
'rest_framework_nested',
|
2016-11-16 20:37:35 +00:00
|
|
|
'rest_framework_swagger',
|
2016-10-08 16:35:22 +00:00
|
|
|
'webpack_loader',
|
2016-11-10 17:26:04 +00:00
|
|
|
# '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 = [
|
2016-11-10 17:26:04 +00:00
|
|
|
# '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',
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
2016-10-04 20:36:08 +00:00
|
|
|
# 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'),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-10-07 23:07:47 +00:00
|
|
|
# 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',
|
2016-10-11 22:08:01 +00:00
|
|
|
# 'filters': ['require_debug_true'],
|
2016-10-07 23:07:47 +00:00
|
|
|
'class': 'logging.StreamHandler',
|
|
|
|
'formatter': 'simple'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'loggers': {
|
|
|
|
'django': {
|
|
|
|
'handlers': ['console'],
|
|
|
|
'propagate': True,
|
2016-12-10 18:28:34 +00:00
|
|
|
'level': 'WARNING',
|
2016-10-07 23:07:47 +00:00
|
|
|
},
|
|
|
|
'app.logger': {
|
|
|
|
'handlers': ['console'],
|
|
|
|
'level': 'INFO',
|
2016-10-24 18:14:35 +00:00
|
|
|
},
|
|
|
|
'apscheduler.executors.default': {
|
|
|
|
'handlers': ['console'],
|
2016-12-10 18:28:34 +00:00
|
|
|
'level': 'WARNING',
|
2016-10-07 23:07:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-10 20:23:17 +00:00
|
|
|
# Auth
|
2016-08-13 17:57:24 +00:00
|
|
|
LOGIN_REDIRECT_URL = '/dashboard/'
|
2016-09-10 15:24:16 +00:00
|
|
|
LOGIN_URL = '/login/'
|
|
|
|
|
|
|
|
# File uploads
|
2016-10-13 20:28:32 +00:00
|
|
|
MEDIA_ROOT = os.path.join(BASE_DIR, 'app', 'media')
|
2016-09-11 21:18:39 +00:00
|
|
|
|
2016-09-22 22:18:35 +00:00
|
|
|
# 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': [
|
2016-10-07 23:07:47 +00:00
|
|
|
'app.permissions.GuardianObjectPermissions',
|
|
|
|
],
|
|
|
|
'DEFAULT_FILTER_BACKENDS': [
|
2016-10-11 22:08:01 +00:00
|
|
|
'rest_framework.filters.DjangoObjectPermissionsFilter',
|
|
|
|
'rest_framework.filters.DjangoFilterBackend',
|
2016-11-04 18:19:18 +00:00
|
|
|
'rest_framework.filters.OrderingFilter',
|
2016-09-30 19:07:09 +00:00
|
|
|
],
|
2017-02-08 17:30:11 +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,
|
|
|
|
}
|
|
|
|
|
2017-02-08 19:14:24 +00:00
|
|
|
JWT_AUTH = {
|
|
|
|
'JWT_EXPIRATION_DELTA': datetime.timedelta(hours=6),
|
|
|
|
}
|
|
|
|
|
2016-10-24 18:14:35 +00:00
|
|
|
TESTING = sys.argv[1:2] == ['test']
|
2017-02-07 16:43:17 +00:00
|
|
|
if TESTING:
|
|
|
|
MEDIA_ROOT = os.path.join(BASE_DIR, 'app', 'media_test')
|
2016-10-24 18:14:35 +00:00
|
|
|
|
2016-09-11 21:18:39 +00:00
|
|
|
try:
|
|
|
|
from .local_settings import *
|
|
|
|
except ImportError:
|
2017-02-11 15:25:00 +00:00
|
|
|
pass
|