diff --git a/config/settings/common.py b/config/settings/common.py index 9540c55..2d8a916 100644 --- a/config/settings/common.py +++ b/config/settings/common.py @@ -404,6 +404,8 @@ CELERY_RESULT_SERIALIZER = 'json' # django-compressor # ------------------------------------------------------------------------------ INSTALLED_APPS += ("compressor", 'sass_processor',) +INSTALLED_APPS += ('django_extensions', ) +INSTALLED_APPS += ('storages', ) STATICFILES_FINDERS += ("compressor.finders.CompressorFinder", ) # Location of root django.contrib.admin URL, use {% url 'admin:index' %} diff --git a/config/settings/local.py b/config/settings/local.py index 374aa74..6295afc 100644 --- a/config/settings/local.py +++ b/config/settings/local.py @@ -77,10 +77,6 @@ DEBUG_TOOLBAR_CONFIG = { 'SHOW_TEMPLATE_CONTEXT': True, } -# django-extensions -# ------------------------------------------------------------------------------ -INSTALLED_APPS += ('django_extensions', ) -INSTALLED_APPS += ('storages', ) # TESTING # ------------------------------------------------------------------------------ @@ -99,6 +95,14 @@ CAPTCHA = { } +# LOGGING CONFIGURATION +# ------------------------------------------------------------------------------ +# See: https://docs.djangoproject.com/en/dev/ref/settings/#logging +# A sample logging configuration. The only tangible logging +# performed by this configuration is to send an email to +# the site admins on every HTTP 500 error when DEBUG=False. +# See http://docs.djangoproject.com/en/dev/topics/logging for +# more details on how to customize your logging configuration. LOGGING = { 'version': 1, 'disable_existing_loggers': False, @@ -124,33 +128,50 @@ LOGGING = { 'class': 'logging.StreamHandler', 'formatter': 'verbose', }, + 'logfile': { + 'level':'DEBUG', + 'class':'logging.FileHandler', + 'filename': "/tmp/django.log" + }, }, 'loggers': { 'django.request': { - 'handlers': ['mail_admins'], + 'handlers': ['mail_admins', 'logfile'], 'level': 'ERROR', 'propagate': True }, 'django.security.DisallowedHost': { 'level': 'ERROR', - 'handlers': ['console', 'mail_admins'], + 'handlers': ['logfile', 'console', 'mail_admins'], 'propagate': True } } } +# Custom Admin URL, use {% url 'admin:index' %} +ADMIN_URL = env('DJANGO_ADMIN_URL', default='trustee/') + +# Your production stuff: Below this line define 3rd party library settings +# ------------------------------------------------------------------------------ + + PAYMENT_PROVIDERS['gocardless']['redirect_url'] = 'http://127.0.0.1:8180' TEMPLATE_DEBUG = False AWS_S3_SECURE_URLS = False AWS_ACCESS_KEY_ID = env('MINIO_ACCESS_KEY') AWS_SECRET_ACCESS_KEY = env('MINIO_SECRET_KEY') - -AWS_S3_ENDPOINT_URL = 'http://%s:9000' % socket.gethostbyname('bucket') AWS_STORAGE_BUCKET_NAME = 'static' +AWS_S3_ENDPOINT_URL = 'http://%s:9000' % socket.gethostbyname('bucket') AWS_S3_OBJECT_PARAMETERS = { 'CacheControl': 'max-age=86400', } +AWS_LOCATION = 'dev' AWS_S3_SECURE_URLS = True STATIC_URL = '%s/%s/' % (AWS_S3_ENDPOINT_URL, AWS_STORAGE_BUCKET_NAME) STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' + +# COMPRESSOR +# ------------------------------------------------------------------------------ +COMPRESS_ENABLED = env.bool('COMPRESS_ENABLED', default=True) +COMPRESS_STORAGE = STATICFILES_STORAGE diff --git a/config/settings/production.py b/config/settings/production.py index fb239bc..c888ce8 100644 --- a/config/settings/production.py +++ b/config/settings/production.py @@ -108,6 +108,9 @@ EMAIL_HOST = 'smtp.gmail.com' EMAIL_HOST_PASSWORD = env('EMAIL_PASSWORD') EMAIL_HOST_USER = env('EMAIL_USER') EMAIL_PORT = 587 +EMAIL_NOTIFY = True + +MSG_PREFIX = 'MH' # Anymail with Mailgun #INSTALLED_APPS += ("anymail", ) @@ -210,7 +213,7 @@ LOGGING = { } # Custom Admin URL, use {% url 'admin:index' %} -ADMIN_URL = env('DJANGO_ADMIN_URL', default='trustee') +ADMIN_URL = env('DJANGO_ADMIN_URL', default='trustee/') # Your production stuff: Below this line define 3rd party library settings # ------------------------------------------------------------------------------ @@ -233,5 +236,6 @@ STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' # COMPRESSOR # ------------------------------------------------------------------------------ +COMPRESS_ENABLED = env.bool('COMPRESS_ENABLED', default=True) COMPRESS_STORAGE = STATICFILES_STORAGE COMPRESS_ENABLED = env.bool('COMPRESS_ENABLED', default=True) diff --git a/config/settings/stage.py b/config/settings/stage.py index 22ac94b..7b7aafd 100644 --- a/config/settings/stage.py +++ b/config/settings/stage.py @@ -17,7 +17,7 @@ from .common import * # noqa # See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key # Raises ImproperlyConfigured exception if DJANGO_SECRET_KEY not in os.environ SECRET_KEY = env('DJANGO_SECRET_KEY') -SITE_ID = 2 + # This ensures that Django will be able to detect a secure connection # properly on Heroku. @@ -90,10 +90,10 @@ AWS_HEADERS = { # MEDIA_URL = '' -# COMPRESSOR -# ------------------------------------------------------------------------------ -# COMPRESS_STORAGE = 'storages.backends.s3boto.S3BotoStorage' -COMPRESS_ENABLED = env.bool('COMPRESS_ENABLED', default=True) +# Static Assets +# ------------------------ +# STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' +# STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage' # EMAIL # ------------------------------------------------------------------------------ DEFAULT_FROM_EMAIL = env('DJANGO_DEFAULT_FROM_EMAIL', @@ -108,7 +108,7 @@ EMAIL_HOST = 'smtp.gmail.com' EMAIL_HOST_PASSWORD = env('EMAIL_PASSWORD') EMAIL_HOST_USER = env('EMAIL_USER') EMAIL_PORT = 587 -EMAIL_NOTIFY = False +EMAIL_NOTIFY = True MSG_PREFIX = 'MHS' @@ -139,7 +139,7 @@ DATABASES['default'] = env.db('DATABASE_URL') # CACHING # ------------------------------------------------------------------------------ -REDIS_LOCATION = '{0}/{1}'.format(env('REDIS_URL', default='redis://127.0.0.1:6379'), 0) +REDIS_LOCATION = '{0}/{1}'.format(env('REDIS_URL', default='redis://redis:6379'), 0) # Heroku URL does not pass the DB number, so we parse it in CACHES = { 'default': { @@ -195,7 +195,7 @@ LOGGING = { 'logfile': { 'level':'DEBUG', 'class':'logging.FileHandler', - 'filename': "/tmp/django.log" + 'filename': "/tmp/django.log" }, }, 'loggers': { @@ -233,3 +233,8 @@ AWS_LOCATION = 'stage' STATIC_URL = '%s/%s/%s/' % (AWS_S3_ENDPOINT_URL, AWS_STORAGE_BUCKET_NAME, AWS_LOCATION) STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' + +# COMPRESSOR +# ------------------------------------------------------------------------------ +COMPRESS_ENABLED = env.bool('COMPRESS_ENABLED', default=True) +COMPRESS_STORAGE = STATICFILES_STORAGE diff --git a/config/wsgi.py b/config/wsgi.py index 73fa5aa..9d177e9 100644 --- a/config/wsgi.py +++ b/config/wsgi.py @@ -17,7 +17,6 @@ import os from django.core.wsgi import get_wsgi_application - # We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks # if running multiple sites in the same mod_wsgi process. To fix this, use # mod_wsgi daemon mode with each site in its own daemon process, or use @@ -32,3 +31,7 @@ application = get_wsgi_application() # Apply WSGI middleware here. # from helloworld.wsgi import HelloWorldApplication # application = HelloWorldApplication(application) +# apply Werkzeug WSGI middleware +if os.environ.setdefault('DEBUG', 'False') is True: + from werkzeug.debug import DebuggedApplication + application = DebuggedApplication(application, evalex=True)