Commit a2146855 authored by Evili del Rio's avatar Evili del Rio

Adapt to django_heroku and its settings

parent 6edf2811
This diff is collapsed.
......@@ -10,6 +10,7 @@ For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.9/ref/settings/
"""
import django_heroku
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
......@@ -122,3 +123,5 @@ USE_TZ = True
STATIC_URL = '/static/'
STATIC_ROOT='/tmp/static'
django_heroku.settings(locals())
import os
from . import *
STATIC_ROOT = '/tmp/static'
#
# POSTGRES_PORT should be named POSTGRES_URL (or similar)
# Here we try to parse it and put (true) port and host
# on the corresponding vars.
#
from urllib.parse import urlparse
_DB_PORT = os.environ.get('POSTGRES_PORT', '5432')
_DB_PARSED = urlparse(_DB_PORT)
if _DB_PARSED.netloc:
# true url found
_DB_PORT = _DB_PARSED.port
_DB_HOST = _DB_PARSED.hostname
else:
# not an url, suppose it's just a port number
_DB_HOST = os.environ.get('POSTGRES_HOST', 'postgres'),
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.environ.get('POSTGRES_DB','test'),
'USER': os.environ.get('POSTGRES_USER', 'postgres'),
'PASSWORD': os.environ.get('POSTGRES_PASSWORD', 'postgres'),
'HOST': _DB_HOST,
'PORT': _DB_PORT,
},
}
#!/usr/bin/env bash
set -x
# Syntax sugar.
BIN_DIR=$(cd "$(dirname "$0")" || return; pwd) # absolute path
# shellcheck source=bin/utils
source "$BIN_DIR/utils"
# Locale support for Pipenv.
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
DISABLE_COLLECTSTATIC=1 INSTALL_TEST=1 "$(dirname "${0:-}")/compile" "$1" "$2" "$3"
# Location of 'manage.py', if it exists.
MANAGE_FILE=$(find . -maxdepth 3 -type f -name 'manage.py' -printf '%d\t%P\n' | sort -nk1 | cut -f2 | head -1)
MANAGE_FILE=${MANAGE_FILE:-fakepath}
# Ensure that Django is explicitly specified in requirements.txt
#sp-grep -s django && DJANGO_INSTALLED=1
DJANGO_INSTALLED=1
if [ -f "$MANAGE_FILE" ] && [ "$DJANGO_INSTALLED" ]; then
set +e
puts-step "$ python $MANAGE_FILE test"
# Run collectstatic, cleanup some of the noisy output.
PYTHONPATH=${PYTHONPATH:-.}
export PYTHONPATH
# Create a temporary file for collecting the collectstaic logs.
TEST_LOG=$(mktemp)
python "$MANAGE_FILE" test 2>&1 | tee "$TEST_LOG"
TEST_STATUS="${PIPESTATUS[0]}"
set -e
# Display a warning if test failed.
[ "$TEST_STATUS" -ne 0 ] && {
echo
echo " ! Error while running '$ python $MANAGE_FILE test'."
echo " See traceback above for details."
echo
exit 1
}
echo
fi
Markdown is supported
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