From f8a5b8e24fe4751b9d22d121b152fb14e9f78932 Mon Sep 17 00:00:00 2001 From: Charles Connell Date: Wed, 14 May 2014 12:33:20 -0400 Subject: [PATCH] heroku conversion step 1 --- Procfile | 1 + fabfile.py | 2 +- karmaworld/settings/common.py | 16 ++---------- karmaworld/settings/dev.py | 16 ++---------- karmaworld/settings/prod.py | 18 -------------- karmaworld/settings/vmdev.py | 7 ------ karmaworld/urls.py | 8 ++++++ karmaworld/wsgi.py | 5 ++-- reqs/common.txt | 2 ++ reqs/prod.txt | 1 - requirements.txt | 46 +++++++++++++++++++++++++++++++++++ 11 files changed, 65 insertions(+), 57 deletions(-) create mode 100644 Procfile create mode 100644 requirements.txt diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..3b127ce --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: gunicorn karmaworld.wsgi diff --git a/fabfile.py b/fabfile.py index eca1e83..1f0320e 100644 --- a/fabfile.py +++ b/fabfile.py @@ -262,7 +262,7 @@ def check_secrets(): """ secrets_path = env.code_root + '/karmaworld/secret' - secrets_files = ('filepicker.py', 'static_s3.py', 'db_settings.py', 'drive.py', 'client_secrets.json', 'drive.p12') + secrets_files = ('filepicker.py', 'static_s3.py', 'drive.py', 'client_secrets.json', 'drive.p12') errors = [] for sfile in secrets_files: diff --git a/karmaworld/settings/common.py b/karmaworld/settings/common.py index 173ab0c..f387ca4 100644 --- a/karmaworld/settings/common.py +++ b/karmaworld/settings/common.py @@ -2,15 +2,12 @@ # -*- coding:utf8 -*- # Copyright (C) 2012 FinalsClub Foundation """ Common settings and globals. """ - - from datetime import timedelta import sys from os.path import abspath, basename, dirname, join, normpath from sys import path - from djcelery import setup_loader - +import dj_database_url from karmaworld.secret.filepicker import FILEPICKER_API_KEY as fp_api FILEPICKER_API_KEY = fp_api @@ -74,16 +71,7 @@ MANAGERS = ADMINS ########## DATABASE CONFIGURATION # See: https://docs.djangoproject.com/en/dev/ref/settings/#databases -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.', - 'NAME': '', - 'USER': '', - 'PASSWORD': '', - 'HOST': '', - 'PORT': '', - } -} +DATABASES = {'default': dj_database_url.config()} ########## END DATABASE CONFIGURATION diff --git a/karmaworld/settings/dev.py b/karmaworld/settings/dev.py index 17a3822..d563696 100644 --- a/karmaworld/settings/dev.py +++ b/karmaworld/settings/dev.py @@ -24,20 +24,6 @@ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' ########## END EMAIL CONFIGURATION -########## DATABASE CONFIGURATION -# See: https://docs.djangoproject.com/en/dev/ref/settings/#databases -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.postgresql_psycopg2', - 'NAME': 'karmanotes', - 'USER': 'djkarma', - 'PASSWORD': 'karma', - 'HOST': 'localhost', - 'PORT': '', # Set to empty string for default. Not used with sqlite3. - } -} -########## END DATABASE CONFIGURATION - ########## STATIC CONFIG # See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url STATIC_URL = '/static/' @@ -77,6 +63,8 @@ INSTALLED_APPS += ( 'django_nose', ) +DEBUG_TOOLBAR_PATCH_SETTINGS = False + DEBUG_TOOLBAR_PANELS = ( 'debug_toolbar.panels.versions.VersionsPanel', 'debug_toolbar.panels.timer.TimerPanel', diff --git a/karmaworld/settings/prod.py b/karmaworld/settings/prod.py index 8ded87d..04a5bc3 100644 --- a/karmaworld/settings/prod.py +++ b/karmaworld/settings/prod.py @@ -8,10 +8,6 @@ from S3 import CallingFormat from common import * -from karmaworld.secret.db_settings import PROD_DB_NAME -from karmaworld.secret.db_settings import PROD_DB_USERNAME -from karmaworld.secret.db_settings import PROD_DB_PASSWORD - try: # Include email is settings are there from karmaworld.secret.email import SMTP_HOST @@ -51,20 +47,6 @@ if EMAIL: ########## END EMAIL CONFIGURATION -########## DATABASE CONFIGURATION -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.postgresql_psycopg2', - 'NAME': PROD_DB_NAME, - 'USER': PROD_DB_USERNAME, - 'PASSWORD': PROD_DB_PASSWORD, - 'HOST': '', - 'PORT': '', # Set to empty string for default. Not used with sqlite3. - } -} -########## END DATABASE CONFIGURATION - - ########## CACHE CONFIGURATION # See: https://docs.djangoproject.com/en/dev/ref/settings/#caches CACHES = { diff --git a/karmaworld/settings/vmdev.py b/karmaworld/settings/vmdev.py index 6096b8f..619bc8d 100644 --- a/karmaworld/settings/vmdev.py +++ b/karmaworld/settings/vmdev.py @@ -2,21 +2,14 @@ # -*- coding:utf8 -*- # Copyright (C) 2012 FinalsClub Foundation """ Production settings and globals. """ - - from os import environ from datetime import timedelta from S3 import CallingFormat from common import * - from karmaworld.secret.static_s3 import * -from karmaworld.secret.db_settings import PROD_DB_NAME -from karmaworld.secret.db_settings import PROD_DB_USERNAME -from karmaworld.secret.db_settings import PROD_DB_PASSWORD - try: # Include email is settings are there from karmaworld.secret.email import SMTP_HOST diff --git a/karmaworld/urls.py b/karmaworld/urls.py index 28c67c7..780abb7 100644 --- a/karmaworld/urls.py +++ b/karmaworld/urls.py @@ -118,3 +118,11 @@ urlpatterns = patterns('', url(r'^$', CourseListView.as_view(), name='home'), ) + + +if settings.DEBUG: + import debug_toolbar + urlpatterns += patterns('', + url(r'^__debug__/', include(debug_toolbar.urls)), + ) + diff --git a/karmaworld/wsgi.py b/karmaworld/wsgi.py index b29ded5..dd75f20 100644 --- a/karmaworld/wsgi.py +++ b/karmaworld/wsgi.py @@ -14,17 +14,18 @@ framework. """ import os +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "karmaworld.settings.dev") +from dj_static import Cling import djcelery djcelery.setup_loader() -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "karmaworld.settings.prod") # This application object is used by any WSGI server configured to use this # file. This includes Django's development server, if the WSGI_APPLICATION # setting points here. from django.core.wsgi import get_wsgi_application -application = get_wsgi_application() +application = Cling(get_wsgi_application()) # Apply WSGI middleware here. # from helloworld.wsgi import HelloWorldApplication diff --git a/reqs/common.txt b/reqs/common.txt index 60d1d3d..27438b7 100644 --- a/reqs/common.txt +++ b/reqs/common.txt @@ -27,3 +27,5 @@ git+https://github.com/btbonval/django-ajax-selects-cascade.git psycopg2 pyth querystring_parser +gunicorn +dj-database-url diff --git a/reqs/prod.txt b/reqs/prod.txt index 41aa7b5..bd4928c 100644 --- a/reqs/prod.txt +++ b/reqs/prod.txt @@ -1,6 +1,5 @@ -r common.txt cssmin==0.1.4 pylibmc==1.2.3 -gunicorn==0.14.3 jsmin==2.0.2 amqplib==1.0.2 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..567e7a6 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,46 @@ +Django>=1.5.0,<1.6.0 +django-celery==3.0.21 +django-compressor==1.2 +Fabric==1.5.3 +South==0.8.4 +supervisor==3.0b1 +oauth2client==1.0 +urllib3==1.5 +google-api-python-client==1.0 +django-grappelli==2.4.8 +django-taggit +git+https://github.com/btbonval/django-filepicker.git +filemagic==1.6 +requests +beautifulsoup4 +pyopenssl +python-twitter +gdshortener +git+https://github.com/flaptor/indextank-py.git +git+https://github.com/jhilker/html2text.git +django-allauth +boto +django-storages==1.1.4 +django-reversion +django-ajax-selects +git+https://github.com/btbonval/django-ajax-selects-cascade.git +psycopg2 +pyth +querystring_parser +gunicorn +dj-database-url +django-kombu==0.9.4 +django-debug-toolbar +django-debug-toolbar-template-timings +ipython==0.13.1 +ipdb==0.7 +django-extensions==1.0.3 # some extra debugging tools for manage.py +# Testing requirements +django-nose==1.1 +coverage==3.6 +selenium==2.38.4 +mock +cssmin==0.1.4 +pylibmc==1.2.3 +jsmin==2.0.2 +amqplib==1.0.2 -- 2.25.1