Browse Source

Remove IS_HEROKU flag

pull/189/head
Clemens Wolff 5 years ago
parent
commit
89372b6242
3 changed files with 7 additions and 11 deletions
  1. 1
      Dockerfile
  2. 14
      app/app/settings.py
  3. 3
      app/server/tests/test_config.py

1
Dockerfile

@ -33,7 +33,6 @@ RUN pip install --no-cache-dir /deps/*.whl
COPY --from=builder /doccano /doccano
ENV IS_HEROKU="False"
ENV DEBUG="True"
ENV SECRET_KEY="change-me-in-production"
ENV PORT="80"

14
app/app/settings.py

@ -195,6 +195,8 @@ LOGIN_URL = '/login/'
LOGIN_REDIRECT_URL = '/projects/'
LOGOUT_REDIRECT_URL = '/'
django_heroku.settings(locals(), test_runner=False)
# Change 'default' database configuration with $DATABASE_URL.
DATABASES['default'].update(dj_database_url.config(
env='DATABASE_URL',
@ -202,6 +204,10 @@ DATABASES['default'].update(dj_database_url.config(
ssl_require='sslmode' not in furl(env('DATABASE_URL', '')).args,
))
# work-around for dj-database-url: explicitly disable ssl for sqlite
if DATABASES['default'].get('ENGINE') == 'django.db.backends.sqlite3':
DATABASES['default'].get('OPTIONS', {}).pop('sslmode', None)
# Honor the 'X-Forwarded-Proto' header for request.is_secure()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
@ -218,11 +224,3 @@ AZURE_APPINSIGHTS_IKEY = env('AZURE_APPINSIGHTS_IKEY', None)
APPLICATION_INSIGHTS = {
'ikey': AZURE_APPINSIGHTS_IKEY if AZURE_APPINSIGHTS_IKEY else None,
}
# work-around for django-heroku: don't overwrite sslmode outside of heroku
if env.bool('IS_HEROKU', True):
django_heroku.settings(locals(), test_runner=False)
# work-around for dj-database-url: explicitly disable ssl for sqlite
if DATABASES['default'].get('ENGINE') == 'django.db.backends.sqlite3':
DATABASES['default'].get('OPTIONS', {}).pop('sslmode', None)

3
app/server/tests/test_config.py

@ -17,8 +17,7 @@ class TestDatabaseUrl(TestCase):
self._assert_sslmode_is(None)
def test_sslmode_can_be_set_via_database_url(self):
with setenv('DATABASE_URL', 'pgsql://u:p@h/d?sslmode=disabled'), \
setenv('IS_HEROKU', 'False'):
with setenv('DATABASE_URL', 'pgsql://u:p@h/d?sslmode=disabled'):
self._assert_sslmode_is('disabled')
def _assert_sslmode_is(self, expected):

Loading…
Cancel
Save