#!/usr/bin/env bash

SETTINGS_FILE=$(find . -maxdepth 3 -type f -name 'settings.py' | head -1)
PROJECT=$(dirname $SETTINGS_FILE)
MANAGE_FILE=$(find . -maxdepth 3 -type f -name 'manage.py' | head -1)
MANAGE_FILE=${MANAGE_FILE:2}

# Disable injection for new applications.
if [ -f .heroku/injection_disabled ]; then
  DISABLE_INJECTION=1
fi

if [ -f .heroku/collectstatic_disabled ]; then
  DISABLE_COLLECTSTATIC=1
fi

export SETTINGS_FILE MANAGE_FILE PROJECT DISABLE_INJECTION

if [ ! "$DISABLE_INJECTION" ]; then
    source $BIN_DIR/steps/django/injection
fi

echo " !     Notice: settings injection will be deprecated for all new Django "
echo " !     apps on July 1, 2012. Learn more:"
echo " !     https://devcenter.heroku.com/articles/django-injection"

if [ ! "$DISABLE_COLLECTSTATIC" ]; then
    source $BIN_DIR/steps/django/collectstatic
fi

