diff --git a/settings.py b/settings.py index 5408f90d36b8d9aa88497c8db0c69c9511125ba8..1fb07d1bf654756c8654210d3751af420489323f 100644 --- a/settings.py +++ b/settings.py @@ -1,21 +1,28 @@ import os -DEBUG = True +# go through environment variables and override them +def get_from_env(var, default): + if os.environ.has_key(var): + return os.environ[var] + else: + return default + +DEBUG = False TEMPLATE_DEBUG = DEBUG ADMINS = ( - # ('Your Name', 'your_email@domain.com'), + ('Ben Adida', 'ben@adida.net'), ) MANAGERS = ADMINS -DATABASE_ENGINE = 'postgresql_psycopg2' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. -DATABASE_NAME = 'helios' # Or path to database file if using sqlite3. -DATABASE_USER = '' # Not used with sqlite3. -DATABASE_PASSWORD = '' # Not used with sqlite3. -DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. -DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql_psycopg2', + 'NAME': 'helios' + } +} # Local time zone for this installation. Choices can be found here: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name @@ -49,7 +56,7 @@ MEDIA_URL = '' ADMIN_MEDIA_PREFIX = '/media/' # Make this unique, and don't share it with anybody. -SECRET_KEY = 'replaceme' +SECRET_KEY = get_from_env('SECRET_KEY', 'replaceme') # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( @@ -79,6 +86,7 @@ INSTALLED_APPS = ( 'django.contrib.sites', ## needed for queues 'djcelery', + 'djkombu', ## needed for schema migration 'south', ## HELIOS stuff @@ -99,8 +107,8 @@ VOTER_UPLOAD_REL_PATH = "voters/%Y/%m/%d" # Change your email settings -DEFAULT_FROM_EMAIL = 'ben@adida.net' -DEFAULT_FROM_NAME = 'Ben for Helios' +DEFAULT_FROM_EMAIL = get_from_env('DEFAULT_FROM_EMAIL', 'ben@adida.net') +DEFAULT_FROM_NAME = get_from_env('DEFAULT_FROM_NAME', 'Ben for Helios') SERVER_EMAIL = '%s <%s>' % (DEFAULT_FROM_NAME, DEFAULT_FROM_EMAIL) LOGIN_URL = '/auth/' @@ -108,21 +116,21 @@ LOGOUT_ON_CONFIRMATION = True # The two hosts are here so the main site can be over plain HTTP # while the voting URLs are served over SSL. -URL_HOST = "http://localhost:8000" +URL_HOST = get_from_env("URL_HOST", "http://localhost:8000") # IMPORTANT: you should not change this setting once you've created # elections, as your elections' cast_url will then be incorrect. # SECURE_URL_HOST = "https://localhost:8443" -SECURE_URL_HOST = "http://localhost:8000" +SECURE_URL_HOST = get_from_env("SECURE_URL_HOST", "http://localhost:8000") # this additional host is used to iframe-isolate the social buttons, # which usually involve hooking in remote JavaScript, which could be # a security issue. Plus, if there's a loading issue, it blocks the whole # page. Not cool. -SOCIALBUTTONS_URL_HOST= "http://localhost:8000" +SOCIALBUTTONS_URL_HOST= get_from_env("SOCIALBUTTONS_URL_HOST", "http://localhost:8000") # election stuff -SITE_TITLE = 'Helios Election Server' +SITE_TITLE = get_from_env('SITE_TITLE', 'Helios Election Server') # FOOTER links FOOTER_LINKS = [] @@ -160,10 +168,10 @@ LINKEDIN_API_KEY = '' LINKEDIN_API_SECRET = '' # email server -EMAIL_HOST = 'localhost' -EMAIL_PORT = 1025 -EMAIL_HOST_USER = '' -EMAIL_HOST_PASSWORD = '' +EMAIL_HOST = get_from_env('EMAIL_HOST', 'localhost') +EMAIL_PORT = 2525 +EMAIL_HOST_USER = get_from_env('EMAIL_HOST_USER', '') +EMAIL_HOST_PASSWORD = get_from_env('EMAIL_HOST_PASSWORD', '') EMAIL_USE_TLS = False # set up logging @@ -174,11 +182,7 @@ logging.basicConfig( ) # set up django-celery -BROKER_HOST = "localhost" -BROKER_PORT = 5672 -BROKER_USER = "guest" -BROKER_PASSWORD = "guest" -BROKER_VHOST = "/" - import djcelery djcelery.setup_loader() +BROKER_BACKEND = "djkombu.transport.DatabaseTransport" +CELERY_RESULT_DBURI = DATABASES['default']