From 51dc7a776e19adc5ebf136401d0aec9ed963b6c0 2017-08-10 02:56:44 From: Christopher Neugebauer <_@chrisjrn.com> Date: 2017-08-10 02:56:44 Subject: [PATCH] Merge pull request #14 from northbaypython/chrisjrn/herokize Makes the site run on Heroku --- diff --git a/Procfile b/Procfile index 2bdf37a2852eb0a68632830723e74cd84dc28e32..e60f4f01b85c6fc30c6d2d9cef9d7e2d54b6b0ed 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -web: gunicorn --bind=0.0.0.0 --log-file - pinaxcon.wsgi +web: gunicorn pinaxcon.wsgi --log-file - diff --git a/README.rst b/README.rst index 9ba8a2932a4acfef7f937b33e17bdeade21046be..1e72b64645fff554713c9ae6a4b66aad73cd4b07 100644 --- a/README.rst +++ b/README.rst @@ -6,13 +6,19 @@ The website for North Bay Python is a Django application with Symposion and Regi Setup ----- -1. pip install -r requirements +Development +~~~~~~~~~~~ +1. pip install -r requirements/base.txt 2. python manage.py createsuperuser 3. python manage.py loaddata fixtures/* 4. python manage.py migrate +Prod +~~~~ +Use `pip install -r requirements.txt` instead. + Reference Material ------------------ * Registrasion docs are at http://registrasion.readthedocs.io -* Symposion docs are at http://symposion.readthedocs.io \ No newline at end of file +* Symposion docs are at http://symposion.readthedocs.io diff --git a/pinaxcon/settings.py b/pinaxcon/settings.py index 97cc0328b7079eb5b092d6b20c010cb04afaffb9..b78e7ac80cf1860eb36a7e04d963db3d7aee4861 100644 --- a/pinaxcon/settings.py +++ b/pinaxcon/settings.py @@ -15,7 +15,12 @@ DATABASES = { } } -ALLOWED_HOSTS = [] +# HEROKU: Update database configuration with $DATABASE_URL. +import dj_database_url +db_from_env = dj_database_url.config() +DATABASES['default'].update(db_from_env) + +ALLOWED_HOSTS = ["localhost", ".herokuapp.com", ".northbaypython.org"] # Local time zone for this installation. Choices can be found here: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name @@ -216,11 +221,20 @@ FIXTURE_DIRS = [ os.path.join(PROJECT_ROOT, "fixtures"), ] -EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" +# Heroku: Get email configuration from environment variables. + +EMAIL_BACKEND = os.environ.get("DJANGO_EMAIL_BACKEND", "django.core.mail.backends.console.EmailBackend") # noqa +EMAIL_HOST = os.environ.get("DJANGO_EMAIL_HOST", "") +EMAIL_PORT = int(os.environ.get("DJANGO_EMAIL_PORT", 25)) +EMAIL_HOST_USER = os.environ.get("DJANGO_EMAIL_HOST_USER", "") +EMAIL_HOST_PASSWORD = os.environ.get("DJANGO_EMAIL_HOST_PASSWORD", "") +EMAIL_USE_TLS = bool(os.environ.get("DJANGO_EMAIL_USE_TLS", False)) +EMAIL_USE_SSL = bool(os.environ.get("DJANGO_EMAIL_USE_SSL", False)) -ACCOUNT_OPEN_SIGNUP = True +# We need to explicitly switch on signups. +ACCOUNT_OPEN_SIGNUP = bool(os.environ.get("DJANGO_ACCOUNT_OPEN_SIGNUP", False)) ACCOUNT_EMAIL_UNIQUE = True -ACCOUNT_EMAIL_CONFIRMATION_REQUIRED = False +ACCOUNT_EMAIL_CONFIRMATION_REQUIRED = False if DEBUG else True ACCOUNT_LOGIN_REDIRECT_URL = "home" ACCOUNT_LOGOUT_REDIRECT_URL = "home" ACCOUNT_EMAIL_CONFIRMATION_EXPIRE_DAYS = 2 diff --git a/requirements.txt b/requirements.txt index 5ac2679fef19e5f6b0bc43c4cd85930cbea24bed..6301390b352f6b4f382b42128a72261202255c91 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,23 +1,2 @@ -Django==1.9.2 -pinax-theme-bootstrap==7.3.0 -django-user-accounts==1.3.1 -metron==1.3.7 -pinax-eventlog==1.1.1 -dj-static==0.0.6 -dj-database-url==0.4.0 -pinax-pages==0.4.2 -pinax-boxes==2.1.2 -django-libsass==0.7 -django-markdown-deux==1.0.5 - - - -# For testing -django-nose==1.4.3 -coverage==4.0.3 - -# Registrasion -https://github.com/chrisjrn/registrasion/tarball/master#egg=registrasion -https://github.com/pinax/symposion/tarball/ad81810#egg=symposion -https://github.com/chrisjrn/registrasion-stripe/tarball/master#egg=registrasion-stripe -https://github.com/chrisjrn/symposion-bootstrap-templates/tarball/master#egg=symposion-bootstrap-templates +-r requirements/base.txt +-r requirements/heroku.txt diff --git a/requirements/base.txt b/requirements/base.txt new file mode 100644 index 0000000000000000000000000000000000000000..5ac2679fef19e5f6b0bc43c4cd85930cbea24bed --- /dev/null +++ b/requirements/base.txt @@ -0,0 +1,23 @@ +Django==1.9.2 +pinax-theme-bootstrap==7.3.0 +django-user-accounts==1.3.1 +metron==1.3.7 +pinax-eventlog==1.1.1 +dj-static==0.0.6 +dj-database-url==0.4.0 +pinax-pages==0.4.2 +pinax-boxes==2.1.2 +django-libsass==0.7 +django-markdown-deux==1.0.5 + + + +# For testing +django-nose==1.4.3 +coverage==4.0.3 + +# Registrasion +https://github.com/chrisjrn/registrasion/tarball/master#egg=registrasion +https://github.com/pinax/symposion/tarball/ad81810#egg=symposion +https://github.com/chrisjrn/registrasion-stripe/tarball/master#egg=registrasion-stripe +https://github.com/chrisjrn/symposion-bootstrap-templates/tarball/master#egg=symposion-bootstrap-templates diff --git a/requirements/heroku.txt b/requirements/heroku.txt new file mode 100644 index 0000000000000000000000000000000000000000..006e01ac224861618d63dbe9246a3d7a70f4dd38 --- /dev/null +++ b/requirements/heroku.txt @@ -0,0 +1,2 @@ +psycopg2==2.7.3 +gunicorn==19.7.1 diff --git a/runtime.txt b/runtime.txt new file mode 100644 index 0000000000000000000000000000000000000000..4b38fc9ad7899f5e9f5158299ba079d03fe90231 --- /dev/null +++ b/runtime.txt @@ -0,0 +1 @@ +python-2.7.13