2015-07-24 18:28:31 -07:00
|
|
|
import dj_database_url
|
|
|
|
import os
|
2011-10-23 17:54:44 -07:00
|
|
|
|
2015-11-13 12:48:57 -08:00
|
|
|
try:
|
|
|
|
from urlparse import urlparse
|
|
|
|
except ImportError:
|
|
|
|
from urllib import parse as urlparse
|
2014-10-20 16:26:16 -07:00
|
|
|
|
|
|
|
|
2014-10-20 11:11:23 -07:00
|
|
|
if 'DATABASE_URL' in os.environ:
|
2014-10-20 16:26:16 -07:00
|
|
|
|
2015-07-24 18:28:31 -07:00
|
|
|
DATABASES = {'default': dj_database_url.config()}
|
2014-10-20 16:26:16 -07:00
|
|
|
|
2015-07-24 18:28:31 -07:00
|
|
|
es = urlparse(os.environ.get('SEARCHBOX_SSL_URL') or
|
|
|
|
'http://127.0.0.1:9200/')
|
2016-11-01 10:38:42 -07:00
|
|
|
|
2016-11-01 12:59:42 -07:00
|
|
|
port = es.port or 443
|
2014-10-20 16:26:16 -07:00
|
|
|
|
2014-10-20 11:16:12 -07:00
|
|
|
HAYSTACK_CONNECTIONS = {
|
|
|
|
'default': {
|
2014-10-20 16:26:16 -07:00
|
|
|
'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
|
|
|
|
'URL': es.scheme + '://' + es.hostname + ':' + str(port),
|
|
|
|
'INDEX_NAME': 'snipts',
|
2014-10-20 11:16:12 -07:00
|
|
|
},
|
|
|
|
}
|
2014-10-20 16:26:16 -07:00
|
|
|
|
|
|
|
if es.username:
|
2015-07-24 18:28:31 -07:00
|
|
|
HAYSTACK_CONNECTIONS['default']['KWARGS'] = {
|
|
|
|
"http_auth": es.username + ':' + es.password
|
|
|
|
}
|
2014-10-20 16:26:16 -07:00
|
|
|
|
2015-07-24 18:28:31 -07:00
|
|
|
ABSOLUTE_URL_OVERRIDES = {'auth.user': lambda u: "/%s/" % u.username}
|
2016-05-10 08:35:51 -07:00
|
|
|
ACCOUNT_ACTIVATION_DAYS = 14
|
2014-10-20 08:50:04 -07:00
|
|
|
ADMINS = (('Nick Sergeant', 'nick@snipt.net'),)
|
2014-10-20 08:18:08 -07:00
|
|
|
ALLOWED_HOSTS = ['*']
|
|
|
|
AUTH_PROFILE_MODULE = 'accounts.UserProfile'
|
|
|
|
AUTHENTICATION_BACKENDS = ('utils.backends.EmailOrUsernameModelBackend',)
|
2011-10-23 19:44:37 -07:00
|
|
|
BASE_PATH = os.path.dirname(__file__)
|
2016-11-01 12:46:50 -07:00
|
|
|
CSRF_COOKIE_SECURE = True if 'USE_SSL' in os.environ else False
|
2014-10-20 18:08:43 -07:00
|
|
|
DEBUG = True if 'DEBUG' in os.environ else False
|
2016-11-01 12:29:47 -07:00
|
|
|
DEFAULT_FROM_EMAIL = os.environ.get('POSTMARK_EMAIL', 'support@snipt.net')
|
2014-10-20 08:50:04 -07:00
|
|
|
EMAIL_BACKEND = 'postmark.django_backend.EmailBackend'
|
2014-10-20 08:18:08 -07:00
|
|
|
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'
|
|
|
|
INTERNAL_IPS = ('127.0.0.1',)
|
|
|
|
LANGUAGE_CODE = 'en-us'
|
|
|
|
LOGIN_REDIRECT_URL = '/login-redirect/'
|
|
|
|
LOGIN_URL = '/login/'
|
|
|
|
LOGOUT_URL = '/logout/'
|
2012-10-18 19:00:15 -07:00
|
|
|
MANAGERS = ADMINS
|
2014-10-20 08:18:08 -07:00
|
|
|
MEDIA_ROOT = os.path.join(BASE_PATH, 'media/uploads')
|
|
|
|
MEDIA_URL = '/media/uploads/'
|
|
|
|
MESSAGE_STORAGE = 'django.contrib.messages.storage.cookie.CookieStorage'
|
2015-10-12 09:51:31 -07:00
|
|
|
PASSWORD_HASHERS = (
|
|
|
|
'django.contrib.auth.hashers.BCryptPasswordHasher',
|
|
|
|
'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
|
|
|
|
'django.contrib.auth.hashers.PBKDF2PasswordHasher',
|
|
|
|
'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
|
|
|
|
'django.contrib.auth.hashers.SHA1PasswordHasher',
|
|
|
|
'django.contrib.auth.hashers.MD5PasswordHasher',
|
|
|
|
'django.contrib.auth.hashers.CryptPasswordHasher',
|
|
|
|
)
|
2014-10-20 11:11:23 -07:00
|
|
|
POSTMARK_API_KEY = os.environ.get('POSTMARK_API_KEY', '')
|
2014-10-20 08:18:08 -07:00
|
|
|
PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
|
2015-07-24 15:57:33 -07:00
|
|
|
REGISTRATION_EMAIL_HTML = False
|
2014-10-20 08:18:08 -07:00
|
|
|
ROOT_URLCONF = 'urls'
|
2014-10-20 11:11:23 -07:00
|
|
|
SECRET_KEY = os.environ.get('SECRET_KEY', 'changeme')
|
2014-10-20 08:13:02 -07:00
|
|
|
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
2016-11-01 13:25:59 -07:00
|
|
|
SECURE_SSL_REDIRECT = True if 'USE_SSL' in os.environ else False
|
2014-10-20 11:12:45 -07:00
|
|
|
SEND_BROKEN_LINK_EMAILS = False
|
2016-11-01 12:29:47 -07:00
|
|
|
SERVER_EMAIL = os.environ.get('POSTMARK_EMAIL', 'support@snipt.net')
|
2014-10-20 08:18:08 -07:00
|
|
|
SESSION_COOKIE_AGE = 15801100
|
2014-10-20 18:08:43 -07:00
|
|
|
SESSION_COOKIE_SECURE = True if 'USE_SSL' in os.environ else False
|
2014-10-20 08:18:08 -07:00
|
|
|
SITE_ID = 1
|
2014-10-20 19:26:51 -07:00
|
|
|
STATICFILES_DIRS = (os.path.join(BASE_PATH, 'media'),)
|
2015-07-24 18:28:31 -07:00
|
|
|
STATICFILES_FINDERS = ('django.contrib.staticfiles.finders.FileSystemFinder',
|
|
|
|
'django.contrib.staticfiles.finders.AppDirectoriesFinder')
|
2016-11-01 10:57:12 -07:00
|
|
|
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
|
2014-10-20 19:26:51 -07:00
|
|
|
STATIC_ROOT = os.path.join(BASE_PATH, 'static')
|
2014-10-30 19:08:27 -07:00
|
|
|
STATIC_URL = '/static/'
|
2015-07-24 18:28:31 -07:00
|
|
|
TASTYPIE_CANNED_ERROR = """There was an error with your request. The site
|
|
|
|
developers have a record of this error, please email api@snipt.net and
|
|
|
|
we'll help you out."""
|
2016-11-01 09:59:35 -07:00
|
|
|
|
|
|
|
TEMPLATES = [
|
|
|
|
{
|
|
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
|
|
'DIRS': [os.path.join(PROJECT_PATH, 'templates')],
|
|
|
|
'APP_DIRS': True,
|
|
|
|
'OPTIONS': {
|
|
|
|
'context_processors': [
|
|
|
|
'django.template.context_processors.debug',
|
|
|
|
'django.template.context_processors.request',
|
|
|
|
'django.template.context_processors.static',
|
|
|
|
'django.contrib.auth.context_processors.auth',
|
|
|
|
'django.contrib.messages.context_processors.messages',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
2014-10-20 08:18:08 -07:00
|
|
|
TIME_ZONE = 'America/New_York'
|
2014-10-20 18:08:43 -07:00
|
|
|
USE_HTTPS = True if 'USE_SSL' in os.environ else False
|
2011-10-23 17:54:44 -07:00
|
|
|
USE_I18N = True
|
|
|
|
USE_L10N = True
|
2013-03-24 15:15:49 -07:00
|
|
|
USE_TZ = True
|
2012-10-18 19:00:15 -07:00
|
|
|
|
|
|
|
INSTALLED_APPS = (
|
2015-09-24 12:09:02 -07:00
|
|
|
'accounts',
|
|
|
|
'blogs',
|
|
|
|
'django.contrib.admin',
|
2012-10-18 19:00:15 -07:00
|
|
|
'django.contrib.auth',
|
|
|
|
'django.contrib.contenttypes',
|
|
|
|
'django.contrib.humanize',
|
2015-09-24 12:09:02 -07:00
|
|
|
'django.contrib.messages',
|
2012-10-18 19:00:15 -07:00
|
|
|
'django.contrib.sessions',
|
|
|
|
'django.contrib.sites',
|
|
|
|
'django.contrib.staticfiles',
|
2015-09-30 13:33:05 -07:00
|
|
|
'django_extensions',
|
2015-09-24 12:09:02 -07:00
|
|
|
'gunicorn',
|
2012-10-18 19:00:15 -07:00
|
|
|
'haystack',
|
|
|
|
'markdown_deux',
|
|
|
|
'pagination',
|
|
|
|
'postmark',
|
|
|
|
'registration',
|
2015-09-24 12:09:02 -07:00
|
|
|
'snipts',
|
2014-10-20 17:21:05 -07:00
|
|
|
'storages',
|
2012-10-18 19:00:15 -07:00
|
|
|
'taggit',
|
|
|
|
'tastypie',
|
2015-08-17 21:59:29 -07:00
|
|
|
'teams',
|
2015-09-24 12:09:02 -07:00
|
|
|
'user-admin',
|
2012-10-18 19:00:15 -07:00
|
|
|
'utils',
|
|
|
|
)
|
2014-10-20 08:18:08 -07:00
|
|
|
LOGGING = {
|
|
|
|
'version': 1,
|
|
|
|
'disable_existing_loggers': False,
|
|
|
|
'filters': {
|
|
|
|
'require_debug_false': {
|
|
|
|
'()': 'django.utils.log.RequireDebugFalse'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'handlers': {},
|
|
|
|
'loggers': {}
|
|
|
|
}
|
2011-06-01 21:50:18 -07:00
|
|
|
MIDDLEWARE_CLASSES = (
|
2016-11-01 13:25:59 -07:00
|
|
|
'django.middleware.security.SecurityMiddleware',
|
2012-06-04 13:22:00 -07:00
|
|
|
'django.middleware.csrf.CsrfViewMiddleware',
|
2015-10-25 18:09:37 -07:00
|
|
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
2011-06-01 21:50:18 -07:00
|
|
|
'django.middleware.common.CommonMiddleware',
|
2011-10-23 17:54:44 -07:00
|
|
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
2011-06-01 21:50:18 -07:00
|
|
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
2011-10-23 17:54:44 -07:00
|
|
|
'django.contrib.messages.middleware.MessageMiddleware',
|
2011-10-12 08:29:21 -07:00
|
|
|
'pagination.middleware.PaginationMiddleware',
|
2012-06-04 14:09:08 -07:00
|
|
|
'blogs.middleware.BlogMiddleware',
|
2011-06-01 21:50:18 -07:00
|
|
|
)
|
2014-10-20 17:27:51 -07:00
|
|
|
|
|
|
|
try:
|
|
|
|
from settings_local import *
|
|
|
|
except ImportError:
|
|
|
|
pass
|