From 1925086aeca4d9a41c8f3ec48245fc1adbb9fd23 Mon Sep 17 00:00:00 2001 From: Anna Makarudze Date: Sat, 21 Oct 2017 03:34:59 +0200 Subject: [PATCH 1/5] Seperate settings for dev, predev and production --- .gitignore | 1 + oshc/oshc/settings/__init__.py | 0 oshc/oshc/settings/base.py | 131 +++++++++++++++++++++++++++++++ oshc/oshc/settings/dev.py | 5 ++ oshc/oshc/settings/predev.py | 5 ++ oshc/oshc/settings/production.py | 5 ++ 6 files changed, 147 insertions(+) create mode 100644 oshc/oshc/settings/__init__.py create mode 100644 oshc/oshc/settings/base.py create mode 100644 oshc/oshc/settings/dev.py create mode 100644 oshc/oshc/settings/predev.py create mode 100644 oshc/oshc/settings/production.py diff --git a/.gitignore b/.gitignore index 49542c5..ffb3f29 100644 --- a/.gitignore +++ b/.gitignore @@ -79,6 +79,7 @@ celerybeat-schedule .env # virtualenv +.ve/ venv/ ENV/ diff --git a/oshc/oshc/settings/__init__.py b/oshc/oshc/settings/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/oshc/oshc/settings/base.py b/oshc/oshc/settings/base.py new file mode 100644 index 0000000..61dcc03 --- /dev/null +++ b/oshc/oshc/settings/base.py @@ -0,0 +1,131 @@ +""" +Django settings for oshc project. + +For more information on this file, see +https://docs.djangoproject.com/en/1.7/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/1.7/ref/settings/ +""" + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +import os +import dj_database_url +from django.core.exceptions import ImproperlyConfigured + + +def get_env_variable(var_name): + """Get the environment variable or return exception""" + try: + return os.environ[var_name] + except KeyError: + error_msg = 'Set the {} environment variable'.format(var_name) + raise ImproperlyConfigured(error_msg) + + +BASE_DIR = os.path.dirname(os.path.dirname(__file__)) + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = get_env_variable('SECRET_KEY') + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = os.getenv("DEBUG", False) + +ALLOWED_HOSTS = ['*'] + +# Tuple of people who get error notifications +ADMINS = [ + ('Tapasweni Pathak', 'tapaswenipathak@gmail.com'), + ('Nikhita Raghunath', 'nikitaraghunath@gmail.com'), + ('Ibrahim Jarif', 'jarifibrahim@gmail.com'), + ('Amar Prakash Pandey', 'amar.om1994@gmail.com') +] + +# Application definition + +INSTALLED_APPS = ( + 'main', + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +) + +MIDDLEWARE_CLASSES = ( + 'whitenoise.middleware.WhiteNoiseMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +) + +ROOT_URLCONF = 'oshc.urls' + +WSGI_APPLICATION = 'oshc.wsgi.application' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +# Database +# https://docs.djangoproject.com/en/1.7/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + +# Get DATABASE_URL environment variable and update default DATABASE settings +# This setting is required for Heroku +db_from_env = dj_database_url.config() +DATABASES['default'].update(db_from_env) + +# Internationalization +# https://docs.djangoproject.com/en/1.7/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + +# Simplified static file serving. +# https://warehouse.python.org/project/whitenoise/ + +STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage' + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/1.7/howto/static-files/ + +STATIC_URL = '/static/' +PROJECT_PATH = os.path.dirname(os.path.abspath(__file__)) +STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') + +STATICFILES_DIRS = ( + os.path.join(BASE_DIR, 'main/'), +) diff --git a/oshc/oshc/settings/dev.py b/oshc/oshc/settings/dev.py new file mode 100644 index 0000000..9452c62 --- /dev/null +++ b/oshc/oshc/settings/dev.py @@ -0,0 +1,5 @@ +# dev settings +from .base import * + + +DEBUG = os.getenv("DEBUG", False) diff --git a/oshc/oshc/settings/predev.py b/oshc/oshc/settings/predev.py new file mode 100644 index 0000000..576c506 --- /dev/null +++ b/oshc/oshc/settings/predev.py @@ -0,0 +1,5 @@ +# predev settings +from .base import * + + +DEBUG = os.getenv("DEBUG", True) diff --git a/oshc/oshc/settings/production.py b/oshc/oshc/settings/production.py new file mode 100644 index 0000000..337d936 --- /dev/null +++ b/oshc/oshc/settings/production.py @@ -0,0 +1,5 @@ +# production settings +from .base import * + + +DEBUG = os.getenv("DEBUG", False) From 1f773ab0c3120143376a310892cc3cdd6f56af92 Mon Sep 17 00:00:00 2001 From: Anna Makarudze Date: Sat, 21 Oct 2017 03:37:12 +0200 Subject: [PATCH 2/5] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 49542c5..ffb3f29 100644 --- a/.gitignore +++ b/.gitignore @@ -79,6 +79,7 @@ celerybeat-schedule .env # virtualenv +.ve/ venv/ ENV/ From ee9627f2afabb0cbba2ab8853f7a7249ca726352 Mon Sep 17 00:00:00 2001 From: Anna Makarudze Date: Sat, 21 Oct 2017 03:38:37 +0200 Subject: [PATCH 3/5] Update .gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index ffb3f29..49542c5 100644 --- a/.gitignore +++ b/.gitignore @@ -79,7 +79,6 @@ celerybeat-schedule .env # virtualenv -.ve/ venv/ ENV/ From 07459f0ab671b2412b02ccfc673a9e441ad83bad Mon Sep 17 00:00:00 2001 From: Anna Makarudze Date: Fri, 15 Dec 2017 22:17:43 +0200 Subject: [PATCH 4/5] Update .travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index bf83620..825ed81 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,7 @@ install: - pip install coveralls before_script: + - export SECRET_KEY='x1-pogt0-b5owbgq0=ui02-4v)bba!bg&1m8_$)8-&13(907qf' - psql -c 'create database travis_ci_test;' -U postgres - cd oshc/ - python manage.py migrate --noinput From e2722e633f8fd01b4a3a6e20df91e38d6a2671ec Mon Sep 17 00:00:00 2001 From: Anna Makarudze Date: Fri, 15 Dec 2017 22:21:11 +0200 Subject: [PATCH 5/5] Update .gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index ffb3f29..49542c5 100644 --- a/.gitignore +++ b/.gitignore @@ -79,7 +79,6 @@ celerybeat-schedule .env # virtualenv -.ve/ venv/ ENV/