diff --git a/.gitignore b/.gitignore index 0cb5419c4c8716da59ec1f5b3befb69fdd17be2b..316ab5bbac9602a3824c4d3c865af9ba4fd70f8b 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,6 @@ data/ # editors *~ + +# local setup +.memopol.alias diff --git a/bin/dev.sh b/bin/dev.sh new file mode 100755 index 0000000000000000000000000000000000000000..7c24b2b0e1d51d231b3c2461c4b29a012f2eb821 --- /dev/null +++ b/bin/dev.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# Script to setup few usual aliases to facilitate the development +# This aliases should work if you've installed memopol throught the quickstart +# script or the documentation +# It : +#  - Setup automaticaly the venv +#  - Setup Django in DEBUG mode +# You just need to add a line in you're .bashrc or .zshrc to load them: + +REPOROOT="$( readlink -m "${BASH_SOURCE[0]}"/../..)" +ALIASROOT=$REPOROOT"/.memopol.alias" +echo $ALIASROOT +echo "Create a dedicated alias file in $ALIASROOT" +echo "alias memopol-code=\"cd $REPOROOT && source $REPOROOT/memopol_env/bin/activate && DJANGO_DEBUG=True\"" > $ALIASROOT +echo "alias memopol-launch=\"memopol-code && memopol runserver\"" >> $ALIASROOT +echo "alias memopol-update-all=\"memopol-code && bin/update-all\"" >> $ALIASROOT +echo "alias memopol-refresh-scores=\"memopol-code && memopol refresh_scores\"" >> $ALIASROOT + +if [ $SHELL = "/bin/bash" ] +then + echo "Bash detected" + echo "Update $HOME/.bashrc file" + RCSHELL="$HOME/.bashrc" +elif [ $SHELL = "/bin/zsh" ] +then + echo "Zsh detected" + echo "Update $HOME/.zshrc file" + RCSHELL="$HOME/.zshrc" +else + echo "SHELL don't supported. Try using BASH or ZSH, or manually." +fi + +echo "source $ALIASROOT" >> $RCSHELL +source $ALIASROOT + + +echo -e "You can use the following aliases :\n" +echo -e "\t memopol-code : Go into the repository and activate the virtualenv" +echo -e "\t memopol-launch : Run the development server" +echo -e "\t memopoll-update-all : Get all the production data" +echo -e "\t memopol-refresh-scores : Refresh all scores" diff --git a/bin/quickstart.sh b/bin/quickstart.sh index 3a3c9d5d37b1f43ecf00756f942efde28365c0c2..d25ef8b5469702bee7f6cec4e19ff1a534dfbaec 100755 --- a/bin/quickstart.sh +++ b/bin/quickstart.sh @@ -41,6 +41,7 @@ memopol migrate # Import sample data memopol loaddata data_sample.json +memopol refresh_scores echo echo "You're all set!" diff --git a/src/memopol/settings.py b/src/memopol/settings.py index 0ab1d9cb54f044175352b04de510e241e2b46c0e..d2810902777fd892c5603e326b35e135de4f92ff 100644 --- a/src/memopol/settings.py +++ b/src/memopol/settings.py @@ -300,11 +300,15 @@ with open(SECRET_FILE, 'r') as f: # # Add allowed hosts from environment +# Automaticaly add 127.0.0.1 in ALLOWED_HOSTS on DEBUG # if 'DJANGO_ALLOWED_HOSTS' in os.environ: ALLOWED_HOSTS += os.environ.get('DJANGO_ALLOWED_HOSTS').split(',') +if DEBUG: + ALLOWED_HOSTS += ['127.0.0.1', 'localhost'] + # # Raven configuration #