Improve the dev commands and add SQLite support
This commit is contained in:
parent
c9803b22c2
commit
ef29e038b5
21
.env_template
Executable file
21
.env_template
Executable file
|
@ -0,0 +1,21 @@
|
|||
MEDIA_ROOT="$DEV_DIR/media/"
|
||||
EPAY_MERCHANT_NUMBER="123"
|
||||
EPAY_MD5_SECRET="123"
|
||||
COINIFY_API_KEY="123"
|
||||
COINIFY_API_SECRET="123"
|
||||
COINIFY_IPN_SECRET="123"
|
||||
PDF_LETTERHEAD_FILENAME="bornhax.pdf"
|
||||
BANKACCOUNT_IBAN="femfladeflødeboller"
|
||||
BANKACCOUNT_SWIFTBIC="goldmansachs"
|
||||
BANKACCOUNT_REG="1234"
|
||||
BANKACCOUNT_ACCOUNT="56789"
|
||||
TICKET_CATEGORY_ID="1"
|
||||
SECRET_KEY="muchsecret"
|
||||
ALLOWED_HOSTS="127.0.0.1"
|
||||
EMAIL_HOST="localhost"
|
||||
EMAIL_PORT="22"
|
||||
EMAIL_HOST_USER="$USER"
|
||||
EMAIL_HOST_PASSWORD=""
|
||||
EMAIL_USE_TLS=""
|
||||
DEFAULT_FROM_EMAIL="bornhax@localhost"
|
||||
ARCHIVE_EMAIL=""
|
8
Makefile
8
Makefile
|
@ -3,15 +3,15 @@ SETTINGS = bornhack.settings.development
|
|||
all: migrate superuser run
|
||||
|
||||
migrations:
|
||||
./manage.py makemigrations --settings=$(SETTINGS)
|
||||
./dev.sh makemigrations --settings=$(SETTINGS)
|
||||
|
||||
migrate:
|
||||
./manage.py migrate --settings=$(SETTINGS)
|
||||
./dev.sh migrate --settings=$(SETTINGS)
|
||||
|
||||
superuser:
|
||||
./manage.py createsuperuser --settings=$(SETTINGS)
|
||||
./dev.sh createsuperuser --settings=$(SETTINGS)
|
||||
|
||||
run:
|
||||
./manage.py runserver --settings=$(SETTINGS)
|
||||
./dev.sh runserver --settings=$(SETTINGS)
|
||||
|
||||
.PHONY = all migrations migrate superuser run
|
||||
|
|
10
README.md
10
README.md
|
@ -23,12 +23,18 @@ Copy environment file and change settings like DATABASE_URL:
|
|||
|
||||
(venv) $ cp bornhack/settings/env.dist bornhack/settings/.env
|
||||
|
||||
Run `make`
|
||||
Run `make` (removing USE_SQLITE=1 if you want to use postgres)
|
||||
|
||||
(venv) $ make
|
||||
(venv) $ SQLITE=1 make
|
||||
|
||||
Which is equivalent with this:
|
||||
|
||||
(venv) $ ./manage.py migrate --settings=bornhack.settings.development
|
||||
(venv) $ ./manage.py createsuperuser --settings=bornhack.settings.development
|
||||
(venv) $ ./manage.py runserver --settings=bornhack.settings.development
|
||||
|
||||
### Setting up Postgres
|
||||
|
||||
Using Postgres is only necessary for purposes og using Postgis for a few maps on the site.
|
||||
To use default settings and make commands, create a user `bornhack`, password `bornhack`
|
||||
and database `bornhack_dev` to use default setttings.
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import os
|
||||
from .base import *
|
||||
|
||||
# INSTALLED_APPS += ['debug_toolbar', ]
|
||||
|
@ -5,6 +6,14 @@ from .base import *
|
|||
SECRET_KEY = 'bornhack_development'
|
||||
DEBUG = True
|
||||
|
||||
if os.environ.get('USE_SQLITE'):
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': local_dir('../.dev/dev.db'),
|
||||
}
|
||||
}
|
||||
else:
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||
|
|
37
dev.sh
37
dev.sh
|
@ -3,34 +3,17 @@
|
|||
# Directory of this script
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
DEV_DIR="$DIR/.dev"
|
||||
|
||||
if [ ! -d "$DEV_DIR"]
|
||||
if ! [ -f "$DIR/.env" ]
|
||||
then
|
||||
mkdir -p "$DEV_DIR"
|
||||
echo "Creating .env file from template..."
|
||||
echo "MEDIA_ROOT=\"$DIR/.dev/media\"" > "$DIR/bornhack/settings/.env"
|
||||
cat "$DIR/.env_template" >> "$DIR/bornhack/settings/.env"
|
||||
fi
|
||||
|
||||
export MEDIA_ROOT="$DEV_DIR/media/"
|
||||
export EPAY_MERCHANT_NUMBER="123"
|
||||
export EPAY_MD5_SECRET="123"
|
||||
export COINIFY_API_KEY="123"
|
||||
export COINIFY_API_SECRET="123"
|
||||
export COINIFY_IPN_SECRET="123"
|
||||
export PDF_LETTERHEAD_FILENAME="bornhax.pdf"
|
||||
export BANKACCOUNT_IBAN="femfladeflødeboller"
|
||||
export BANKACCOUNT_SWIFTBIC="goldmansachs"
|
||||
export BANKACCOUNT_REG="1234"
|
||||
export BANKACCOUNT_ACCOUNT="56789"
|
||||
export TICKET_CATEGORY_ID="1"
|
||||
export SECRET_KEY="muchsecret"
|
||||
export ALLOWED_HOSTS="127.0.0.1"
|
||||
export DATABASE_URL="sqlite:///$DEV_DIR/dev.db"
|
||||
export EMAIL_HOST="localhost"
|
||||
export EMAIL_PORT="22"
|
||||
export EMAIL_HOST_USER="$USER"
|
||||
export EMAIL_HOST_PASSWORD=""
|
||||
export EMAIL_USE_TLS=""
|
||||
export DEFAULT_FROM_EMAIL="bornhax@localhost"
|
||||
export ARCHIVE_EMAIL=""
|
||||
if ! [ -d "$DIR/.dev" ]
|
||||
then
|
||||
echo "Creating .dev dir for development stuff"
|
||||
mkdir -p "$DIR/.dev/media"
|
||||
fi
|
||||
|
||||
python manage.py $@ --settings=bornhack.settings.development
|
||||
python "$DIR/manage.py" $@ --settings=bornhack.settings.development
|
||||
|
|
Loading…
Reference in a new issue