forked from wiktor/spejstore-new
settings: load all relevant options from environment
This commit is contained in:
parent
fedf3dca80
commit
43c1c94844
|
@ -3,3 +3,8 @@ db.sqlite3
|
||||||
*.swp
|
*.swp
|
||||||
spejstore.env
|
spejstore.env
|
||||||
env/
|
env/
|
||||||
|
backups
|
||||||
|
media/
|
||||||
|
django-tree/
|
||||||
|
postgres-hstore/
|
||||||
|
.ropeproject/
|
||||||
|
|
|
@ -12,6 +12,10 @@ https://docs.djangoproject.com/en/1.10/ref/settings/
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
def env(name, default=None):
|
||||||
|
return os.getenv('SPEJSTORE_' + name, default)
|
||||||
|
|
||||||
|
|
||||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
STATIC_ROOT = os.path.join(BASE_DIR, 'build_static')
|
STATIC_ROOT = os.path.join(BASE_DIR, 'build_static')
|
||||||
|
@ -21,12 +25,12 @@ PROD = os.getenv('SPEJSTORE_ENV') == 'prod'
|
||||||
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
|
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
|
||||||
|
|
||||||
# SECURITY WARNING: keep the secret key used in production secret!
|
# SECURITY WARNING: keep the secret key used in production secret!
|
||||||
SECRET_KEY = '#hjthi7_udsyt*9eeyb&nwgw5x=%pk_lnz3+u2tg9@=w3p1m*k'
|
SECRET_KEY = env('SECRET_KEY', '#hjthi7_udsyt*9eeyb&nwgw5x=%pk_lnz3+u2tg9@=w3p1m*k')
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = not PROD
|
DEBUG = not PROD
|
||||||
|
|
||||||
ALLOWED_HOSTS = ['devinventory', 'inventory.waw.hackerspace.pl', 'i', 'inventory']
|
ALLOWED_HOSTS = env('ALLOWED_HOSTS', 'devinventory,inventory.waw.hackerspace.pl,i,inventory').split(',')
|
||||||
LOGIN_REDIRECT_URL = '/admin/'
|
LOGIN_REDIRECT_URL = '/admin/'
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,11 +97,12 @@ WSGI_APPLICATION = 'spejstore.wsgi.application'
|
||||||
|
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
'ENGINE': env('DB_ENGINE', 'django.db.backends.postgresql_psycopg2'),
|
||||||
'NAME': 'postgres',
|
'NAME': env('DB_NAME', 'postgres'),
|
||||||
'USER': 'postgres',
|
'USER': env('DB_USER', 'postgres'),
|
||||||
'HOST': 'db',
|
'PASSWORD': env('DB_PASSWORD', None),
|
||||||
'PORT': 5432,
|
'HOST': env('DB_HOST', 'db'),
|
||||||
|
'PORT': env('DB_PORT', 5432),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,27 +154,21 @@ SOCIAL_AUTH_PIPELINE = (
|
||||||
# https://docs.djangoproject.com/en/1.10/topics/i18n/
|
# https://docs.djangoproject.com/en/1.10/topics/i18n/
|
||||||
|
|
||||||
LANGUAGE_CODE = 'en-us'
|
LANGUAGE_CODE = 'en-us'
|
||||||
|
|
||||||
TIME_ZONE = 'UTC'
|
TIME_ZONE = 'UTC'
|
||||||
|
|
||||||
USE_I18N = True
|
USE_I18N = True
|
||||||
|
|
||||||
USE_L10N = True
|
USE_L10N = True
|
||||||
|
|
||||||
USE_TZ = True
|
USE_TZ = True
|
||||||
|
|
||||||
|
|
||||||
# Static files (CSS, JavaScript, Images)
|
# Static files (CSS, JavaScript, Images)
|
||||||
# https://docs.djangoproject.com/en/1.10/howto/static-files/
|
# https://docs.djangoproject.com/en/1.10/howto/static-files/
|
||||||
|
|
||||||
STATIC_URL = '/static/'
|
STATIC_URL = '/static/'
|
||||||
|
|
||||||
STATICFILES_DIRS = [
|
STATICFILES_DIRS = [
|
||||||
os.path.join(BASE_DIR, "static"),
|
os.path.join(BASE_DIR, "static"),
|
||||||
]
|
]
|
||||||
|
|
||||||
MEDIA_URL = '/media/'
|
MEDIA_URL = '/media/'
|
||||||
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
|
MEDIA_ROOT = env('MEDIA_ROOT', os.path.join(BASE_DIR, "media"))
|
||||||
|
|
||||||
# REST Framework
|
# REST Framework
|
||||||
REST_FRAMEWORK = {
|
REST_FRAMEWORK = {
|
||||||
|
@ -185,10 +184,10 @@ REST_FRAMEWORK = {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
SOCIAL_AUTH_HSWAW_KEY = os.getenv('SPEJSTORE_CLIENT_ID')
|
SOCIAL_AUTH_HSWAW_KEY = env('CLIENT_ID')
|
||||||
SOCIAL_AUTH_HSWAW_SECRET = os.getenv('SPEJSTORE_SECRET')
|
SOCIAL_AUTH_HSWAW_SECRET = env('SECRET')
|
||||||
SOCIAL_AUTH_REDIRECT_IS_HTTPS = PROD
|
SOCIAL_AUTH_REDIRECT_IS_HTTPS = PROD
|
||||||
|
|
||||||
SOCIAL_AUTH_POSTGRES_JSONFIELD = True
|
SOCIAL_AUTH_POSTGRES_JSONFIELD = True
|
||||||
|
|
||||||
LABEL_API = 'http://label.waw.hackerspace.pl:4567'
|
LABEL_API = env('LABEL_API', 'http://label.waw.hackerspace.pl:4567')
|
||||||
|
|
Loading…
Reference in New Issue