diff --git a/.env_template b/.env_template deleted file mode 100755 index 15174ce8..00000000 --- a/.env_template +++ /dev/null @@ -1,21 +0,0 @@ -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="304e9b44-0b48-472d-a05b-963e52614a69" -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="" diff --git a/README.md b/README.md index 44caa25a..5d78b366 100644 --- a/README.md +++ b/README.md @@ -1,44 +1,36 @@ # Bornhack -Django project to power Bornhack. - -Features do not include: -- Create camp -- Control expenses for a camp -- Manage signups for attendees for a camp -- ... +Django project to power Bornhack. Features include news, villages, webshop, and more. ## Quickstart +### Virtualenv Create a Python 2.7 virtual environment and activate it: - $ virtualenv venv $ source venv/bin/activate -Install dependencies: +### System libraries +Install system dependencies (method depends on OS): +- postgresql headers (for psychopg2) +- libjpeg (for pdf generation) +### Python packages +Install pip packages (pick either development or production): (venv) $ pip install -r requirements/development.txt + (venv) $ pip install -r requirements/production.txt -Copy environment file and change settings like DATABASE_URL: - +### Configuration file +Copy environment file template and change settings: (venv) $ cp bornhack/settings/env.dist bornhack/settings/.env -Run `make` (removing USE_SQLITE=1 if you want to use postgres) - - (venv) $ SQLITE=1 make - -Which is equivalent with this: - +### Database +Is this a new installation? Initialize the database: (venv) $ ./manage.py migrate --settings=bornhack.settings.development (venv) $ ./manage.py createsuperuser --settings=bornhack.settings.development + +### Done +Is this for local development? Start the Django devserver: (venv) $ ./manage.py runserver --settings=bornhack.settings.development -### Setting up Postgres +Otherwise start uwsgi or similar to serve the application. -Using Postgres is only necessary for purposes of the special -[JSONField](https://docs.djangoproject.com/en/1.10/ref/contrib/postgres/fields/). -The field is active on our shop mainly, so you can still develop things for most -parts of the site without installing Postgres. - -To use default settings and make commands, create a user `bornhack`, password -`bornhack` and database `bornhack_dev` to use default setttings. diff --git a/bornhack/settings/.env.dist b/bornhack/settings/.env.dist new file mode 100644 index 00000000..7d025aed --- /dev/null +++ b/bornhack/settings/.env.dist @@ -0,0 +1,32 @@ +### set database url and allowed_hosts here +DATABASE_URL=postgres://username:password@host:port/database +ALLOWED_HOSTS=localhost,127.0.0.1 + +### changes below here are only needed for production +SECRET_KEY=somethingverysecretandunique + +EMAIL_HOST='mailhost.example.com' +EMAIL_PORT=587 +EMAIL_HOST_USER='mymailuser' +EMAIL_HOST_PASSWORD='mymailpassword' +EMAIL_USE_TLS=True +DEFAULT_FROM_EMAIL='noreply@example.com' +ARCHIVE_EMAIL='archive@example.com' + +ADMINS=( + ('bornhack sysadm', 'sysadm@bornhack.org'), +) + +EPAY_MERCHANT_NUMBER=123 +EPAY_MD5_SECRET='abc' +TICKET_CATEGORY_ID='304e9b44-0b48-472d-a05b-963e52614a69' +COINIFY_API_KEY='123' +COINIFY_API_SECRET='123' +COINIFY_IPN_SECRET='123' +PDF_LETTERHEAD_FILENAME='letterhead.pdf' +MEDIA_ROOT='/path/to/media/root/outside/django/root/' +BANKACCOUNT_IBAN='123' +BANKACCOUNT_SWIFTBIC='123' +BANKACCOUNT_REG='123' +BANKACCOUNT_ACCOUNT='123' + diff --git a/bornhack/settings/base.py b/bornhack/settings/base.py index 3505ecfc..0185c8b9 100644 --- a/bornhack/settings/base.py +++ b/bornhack/settings/base.py @@ -13,8 +13,15 @@ def local_dir(entry): WSGI_APPLICATION = 'bornhack.wsgi.application' ROOT_URLCONF = 'bornhack.urls' +SECRET_KEY = env('SECRET_KEY') +ALLOWED_HOSTS = env('ALLOWED_HOSTS').split(',') + SITE_ID = 1 +DATABASES = { + 'default': env.db(), +} + INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', @@ -40,7 +47,6 @@ INSTALLED_APPS = [ STATIC_URL = '/static/' STATIC_ROOT = local_dir('static') STATICFILES_DIRS = [local_dir('static_src')] -#MEDIA_URL = '/media/' MEDIA_ROOT = env('MEDIA_ROOT') LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' @@ -116,4 +122,4 @@ BANKACCOUNT_SWIFTBIC = env('BANKACCOUNT_SWIFTBIC') BANKACCOUNT_REG = env('BANKACCOUNT_REG') BANKACCOUNT_ACCOUNT = env('BANKACCOUNT_ACCOUNT') -TICKET_CATEGORY_ID = env('TICKET_CATEGORY_ID') \ No newline at end of file +TICKET_CATEGORY_ID = env('TICKET_CATEGORY_ID') diff --git a/bornhack/settings/development.py b/bornhack/settings/development.py index 3ceec81f..90f451a0 100644 --- a/bornhack/settings/development.py +++ b/bornhack/settings/development.py @@ -1,28 +1,11 @@ -import os from .base import * +import environ +env = environ.Env() +environ.Env.read_env() + +DEBUG = True + +EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' # INSTALLED_APPS += ['debug_toolbar', ] -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', - 'NAME': 'bornhack_dev', - 'USER': 'bornhack', - 'PASSWORD': 'bornhack', - 'HOST': 'localhost', - 'PORT': 5432, - } - } - -EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' diff --git a/bornhack/settings/production.py b/bornhack/settings/production.py index ca93b6ce..52b23962 100644 --- a/bornhack/settings/production.py +++ b/bornhack/settings/production.py @@ -1,17 +1,9 @@ from .base import * import environ - env = environ.Env() - environ.Env.read_env() DEBUG = False -SECRET_KEY = env('SECRET_KEY') -ALLOWED_HOSTS = env('ALLOWED_HOSTS').split(',') - -DATABASES = { - 'default': env.db(), -} EMAIL_HOST = env('EMAIL_HOST') EMAIL_PORT = env('EMAIL_PORT') @@ -44,7 +36,5 @@ LOGGING = { } } -ADMINS = ( - ('bornhack sysadm', 'sysadm@bornhack.org'), -) +ADMINS = env('ADMINS')