2017-08-11 18:32:02 +00:00
|
|
|
import os
|
|
|
|
|
2017-12-01 03:54:50 +00:00
|
|
|
from dotenv import load_dotenv, find_dotenv
|
|
|
|
|
2017-08-11 18:32:02 +00:00
|
|
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
2017-08-19 14:16:51 +00:00
|
|
|
BASE_DIR = os.path.dirname(
|
|
|
|
os.path.dirname(
|
|
|
|
os.path.dirname(
|
|
|
|
os.path.abspath(__file__)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
2017-08-11 18:32:02 +00:00
|
|
|
|
2017-12-01 03:54:50 +00:00
|
|
|
# Environment variables
|
|
|
|
# Check for and load environment variables from a .env file.
|
|
|
|
|
|
|
|
load_dotenv(find_dotenv())
|
2017-08-11 18:32:02 +00:00
|
|
|
|
2017-11-29 20:02:14 +00:00
|
|
|
# Required settings
|
2017-10-23 13:49:09 +00:00
|
|
|
|
2017-11-29 20:02:14 +00:00
|
|
|
ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS', '*').split(',')
|
|
|
|
SECRET_KEY = os.environ.get('SECRET_KEY', None)
|
|
|
|
DEBUG = os.environ.get('DEBUG', False)
|
2017-10-23 13:49:09 +00:00
|
|
|
|
|
|
|
|
2017-08-19 14:16:51 +00:00
|
|
|
# Applications
|
|
|
|
# https://docs.djangoproject.com/en/1.11/ref/applications/
|
2017-08-11 18:32:02 +00:00
|
|
|
|
|
|
|
INSTALLED_APPS = [
|
2017-08-13 14:48:16 +00:00
|
|
|
'api',
|
2017-10-22 18:00:42 +00:00
|
|
|
'babybuddy',
|
2017-08-13 14:48:16 +00:00
|
|
|
'core',
|
2017-08-18 13:02:31 +00:00
|
|
|
'dashboard',
|
2017-08-21 23:21:08 +00:00
|
|
|
'reports',
|
2017-08-13 14:48:16 +00:00
|
|
|
|
2017-11-02 10:05:12 +00:00
|
|
|
'django_filters',
|
2017-08-13 14:48:16 +00:00
|
|
|
'rest_framework',
|
2017-12-05 15:46:59 +00:00
|
|
|
'rest_framework.authtoken',
|
2017-08-15 20:50:09 +00:00
|
|
|
'widget_tweaks',
|
2017-11-18 09:22:12 +00:00
|
|
|
'easy_thumbnails',
|
2018-02-25 06:13:39 +00:00
|
|
|
'storages',
|
2017-08-13 14:48:16 +00:00
|
|
|
|
2017-08-11 18:32:02 +00:00
|
|
|
'django.contrib.admin',
|
|
|
|
'django.contrib.auth',
|
|
|
|
'django.contrib.contenttypes',
|
|
|
|
'django.contrib.sessions',
|
|
|
|
'django.contrib.messages',
|
|
|
|
'django.contrib.staticfiles',
|
|
|
|
]
|
|
|
|
|
2017-08-19 14:16:51 +00:00
|
|
|
# Middleware
|
|
|
|
# https://docs.djangoproject.com/en/1.11/ref/middleware/
|
|
|
|
|
2017-08-11 18:32:02 +00:00
|
|
|
MIDDLEWARE = [
|
|
|
|
'django.middleware.security.SecurityMiddleware',
|
2017-10-23 09:07:35 +00:00
|
|
|
|
|
|
|
'whitenoise.middleware.WhiteNoiseMiddleware',
|
|
|
|
|
2017-08-11 18:32:02 +00:00
|
|
|
'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',
|
|
|
|
]
|
|
|
|
|
2017-08-19 14:16:51 +00:00
|
|
|
|
|
|
|
# URL dispatcher
|
|
|
|
# https://docs.djangoproject.com/en/1.11/topics/http/urls/
|
|
|
|
|
2017-10-22 18:00:42 +00:00
|
|
|
ROOT_URLCONF = 'babybuddy.urls'
|
2017-08-11 18:32:02 +00:00
|
|
|
|
2017-08-19 14:16:51 +00:00
|
|
|
|
|
|
|
# Templates
|
|
|
|
# https://docs.djangoproject.com/en/1.11/ref/templates/upgrading/#the-templates-settings
|
|
|
|
|
2017-08-11 18:32:02 +00: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.contrib.auth.context_processors.auth',
|
|
|
|
'django.contrib.messages.context_processors.messages',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2017-08-19 14:16:51 +00:00
|
|
|
# WGSI
|
|
|
|
# https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/
|
2017-08-11 18:32:02 +00:00
|
|
|
|
2017-10-22 18:00:42 +00:00
|
|
|
WSGI_APPLICATION = 'babybuddy.wsgi.application'
|
2017-08-11 18:32:02 +00:00
|
|
|
|
|
|
|
|
2017-08-16 16:46:26 +00:00
|
|
|
# Authentication
|
|
|
|
# https://docs.djangoproject.com/en/1.11/topics/auth/default/
|
|
|
|
|
|
|
|
LOGIN_REDIRECT_URL = '/'
|
|
|
|
|
|
|
|
LOGIN_URL = '/login/'
|
|
|
|
|
|
|
|
LOGOUT_REDIRECT_URL = '/login/'
|
|
|
|
|
|
|
|
|
2017-08-11 18:32:02 +00:00
|
|
|
# Internationalization
|
|
|
|
# https://docs.djangoproject.com/en/1.11/topics/i18n/
|
|
|
|
|
|
|
|
LANGUAGE_CODE = 'en-us'
|
|
|
|
|
2017-11-29 20:02:14 +00:00
|
|
|
TIME_ZONE = os.environ.get('TIME_ZONE', 'Etc/UTC')
|
2017-08-11 18:32:02 +00:00
|
|
|
|
|
|
|
USE_I18N = True
|
|
|
|
|
|
|
|
USE_L10N = True
|
|
|
|
|
|
|
|
USE_TZ = True
|
|
|
|
|
|
|
|
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
|
|
# https://docs.djangoproject.com/en/1.11/howto/static-files/
|
|
|
|
|
2017-10-23 09:07:35 +00:00
|
|
|
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
|
|
|
|
|
|
|
|
STATICFILES_FINDERS = [
|
|
|
|
'django.contrib.staticfiles.finders.FileSystemFinder',
|
|
|
|
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
|
|
|
]
|
|
|
|
|
2017-08-11 18:32:02 +00:00
|
|
|
STATIC_URL = '/static/'
|
2017-08-13 13:44:48 +00:00
|
|
|
|
2017-08-19 13:50:03 +00:00
|
|
|
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
|
|
|
|
|
2018-02-25 06:13:39 +00:00
|
|
|
WHITENOISE_ROOT = os.path.join(BASE_DIR, 'static', 'root')
|
|
|
|
|
|
|
|
|
|
|
|
# Media files (User uploaded content)
|
|
|
|
# https://docs.djangoproject.com/en/2.0/topics/files/
|
|
|
|
|
2017-11-18 09:22:12 +00:00
|
|
|
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
|
|
|
|
|
2018-02-25 06:13:39 +00:00
|
|
|
MEDIA_URL = '/media/'
|
|
|
|
|
|
|
|
AWS_STORAGE_BUCKET_NAME = os.environ.get('AWS_STORAGE_BUCKET_NAME', None)
|
|
|
|
|
|
|
|
AWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_KEY_ID', None)
|
|
|
|
|
|
|
|
AWS_SECRET_ACCESS_KEY = os.environ.get('AWS_SECRET_ACCESS_KEY', None)
|
|
|
|
|
|
|
|
if AWS_STORAGE_BUCKET_NAME:
|
|
|
|
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
|
|
|
|
THUMBNAIL_DEFAULT_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
|
2017-10-23 19:13:11 +00:00
|
|
|
|
2017-08-13 13:44:48 +00:00
|
|
|
|
|
|
|
# Django Rest Framework
|
|
|
|
# http://www.django-rest-framework.org/#
|
2017-08-19 14:16:51 +00:00
|
|
|
|
2017-08-13 13:44:48 +00:00
|
|
|
REST_FRAMEWORK = {
|
2017-12-05 15:46:59 +00:00
|
|
|
'DEFAULT_AUTHENTICATION_CLASSES': [
|
|
|
|
'rest_framework.authentication.SessionAuthentication',
|
|
|
|
'rest_framework.authentication.TokenAuthentication',
|
|
|
|
],
|
2017-11-02 10:05:12 +00:00
|
|
|
'DEFAULT_FILTER_BACKENDS': [
|
|
|
|
'django_filters.rest_framework.DjangoFilterBackend',
|
|
|
|
],
|
2017-12-06 00:27:28 +00:00
|
|
|
'DEFAULT_METADATA_CLASS': 'api.metadata.APIMetadata',
|
|
|
|
'DEFAULT_PAGINATION_CLASS':
|
|
|
|
'rest_framework.pagination.LimitOffsetPagination',
|
2017-08-13 13:44:48 +00:00
|
|
|
'DEFAULT_PERMISSION_CLASSES': [
|
2017-10-22 18:00:42 +00:00
|
|
|
'api.permissions.BabyBuddyDjangoModelPermissions'
|
2017-08-20 17:31:19 +00:00
|
|
|
],
|
2017-11-02 10:05:12 +00:00
|
|
|
'DEFAULT_RENDERER_CLASSES': [
|
2017-08-20 17:31:19 +00:00
|
|
|
'rest_framework.renderers.JSONRenderer',
|
2017-11-02 10:05:12 +00:00
|
|
|
],
|
2017-10-21 21:36:44 +00:00
|
|
|
'PAGE_SIZE': 100
|
2017-08-13 13:44:48 +00:00
|
|
|
}
|
2017-11-04 11:59:28 +00:00
|
|
|
|
|
|
|
# Baby Buddy configuration
|
2017-11-29 20:02:14 +00:00
|
|
|
# See README.md#configuration for details about these settings.
|
2017-11-04 11:59:28 +00:00
|
|
|
|
|
|
|
BABY_BUDDY = {
|
2017-11-29 20:02:14 +00:00
|
|
|
'NAP_START_MIN': os.environ.get('NAP_START_MIN', '06:00'),
|
2017-12-01 23:07:08 +00:00
|
|
|
'NAP_START_MAX': os.environ.get('NAP_START_MAX', '18:00'),
|
|
|
|
'ALLOW_UPLOADS': os.environ.get('ALLOW_UPLOADS', True)
|
2017-11-04 11:59:28 +00:00
|
|
|
}
|