Commit cde19659 authored by Mathias Lund Ahrn's avatar Mathias Lund Ahrn
Browse files

Fixed cd issues

parent 0c4493a5
Pipeline #113851 passed with stages
in 2 minutes and 54 seconds
......@@ -3,11 +3,11 @@ import os
import dj_database_url
from django.test.runner import DiscoverRunner
from .djangoHeroku import settings
MAX_CONN_AGE = 600
def settings(config, *, db_colors=False, databases=True, test_runner=True, staticfiles=True, allowed_hosts=True, logging=True, secret_key=True):
# Database configuration.
......@@ -18,7 +18,7 @@ def settings(config, *, db_colors=False, databases=True, test_runner=True, stati
config['DATABASES'] = {'default': None}
conn_max_age = config.get('CONN_MAX_AGE', MAX_CONN_AGE)
if db_colors:
# Support all Heroku databases.
# TODO: This appears to break TestRunner.
......@@ -28,13 +28,15 @@ def settings(config, *, db_colors=False, databases=True, test_runner=True, stati
#logger.info('Adding ${} to DATABASES Django setting ({}).'.format(env, db_color))
config['DATABASES'][db_color] = dj_database_url.parse(url, conn_max_age=conn_max_age, ssl_require=True)
config['DATABASES'][db_color] = dj_database_url.parse(
url, conn_max_age=conn_max_age, ssl_require=True)
if 'DATABASE_URL' in os.environ:
#logger.info('Adding $DATABASE_URL to default DATABASE Django setting.')
# Configure Django for DATABASE_URL environment variable.
config['DATABASES']['default'] = dj_database_url.config(conn_max_age=conn_max_age, ssl_require=True)
config['DATABASES']['default'] = dj_database_url.config(
conn_max_age=conn_max_age, ssl_require=True)
#logger.info('Adding $DATABASE_URL to TEST default DATABASE Django setting.')
......@@ -42,7 +44,7 @@ def settings(config, *, db_colors=False, databases=True, test_runner=True, stati
if 'CI' in os.environ:
config['DATABASES']['default']['TEST'] = config['DATABASES']['default']
#else:
# else:
#logger.info('$DATABASE_URL not found, falling back to previous settings!')
if test_runner:
......@@ -62,9 +64,11 @@ def settings(config, *, db_colors=False, databases=True, test_runner=True, stati
# Insert Whitenoise Middleware.
try:
config['MIDDLEWARE_CLASSES'] = tuple(['whitenoise.middleware.WhiteNoiseMiddleware'] + list(config['MIDDLEWARE_CLASSES']))
config['MIDDLEWARE_CLASSES'] = tuple(
['whitenoise.middleware.WhiteNoiseMiddleware'] + list(config['MIDDLEWARE_CLASSES']))
except KeyError:
config['MIDDLEWARE'] = tuple(['whitenoise.middleware.WhiteNoiseMiddleware'] + list(config['MIDDLEWARE']))
config['MIDDLEWARE'] = tuple(
['whitenoise.middleware.WhiteNoiseMiddleware'] + list(config['MIDDLEWARE']))
# Enable GZip.
config['STATICFILES_STORAGE'] = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
......
......@@ -12,6 +12,7 @@ https://docs.djangoproject.com/en/3.1/ref/settings/
from pathlib import Path
import os
from .djangoHeroku import settings
# Get the GROUPID variable to accept connections from the application server and NGINX
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment