Skip to content

Commit d918ef1

Browse files
Merge pull request #200 from amakarudze/anna-predev
settings for dev, predev and production.
2 parents 95a2a05 + e2722e6 commit d918ef1

File tree

6 files changed

+147
-0
lines changed

6 files changed

+147
-0
lines changed

Diff for: .travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ install:
1616
- pip install coveralls
1717

1818
before_script:
19+
- export SECRET_KEY='x1-pogt0-b5owbgq0=ui02-4v)bba!bg&1m8_$)8-&13(907qf'
1920
- psql -c 'create database travis_ci_test;' -U postgres
2021
- cd oshc/
2122
- python manage.py migrate --noinput

Diff for: oshc/oshc/settings/__init__.py

Whitespace-only changes.

Diff for: oshc/oshc/settings/base.py

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
"""
2+
Django settings for oshc project.
3+
4+
For more information on this file, see
5+
https://docs.djangoproject.com/en/1.7/topics/settings/
6+
7+
For the full list of settings and their values, see
8+
https://docs.djangoproject.com/en/1.7/ref/settings/
9+
"""
10+
11+
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
12+
import os
13+
import dj_database_url
14+
from django.core.exceptions import ImproperlyConfigured
15+
16+
17+
def get_env_variable(var_name):
18+
"""Get the environment variable or return exception"""
19+
try:
20+
return os.environ[var_name]
21+
except KeyError:
22+
error_msg = 'Set the {} environment variable'.format(var_name)
23+
raise ImproperlyConfigured(error_msg)
24+
25+
26+
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
27+
28+
# Quick-start development settings - unsuitable for production
29+
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
30+
31+
# SECURITY WARNING: keep the secret key used in production secret!
32+
SECRET_KEY = get_env_variable('SECRET_KEY')
33+
34+
# SECURITY WARNING: don't run with debug turned on in production!
35+
DEBUG = os.getenv("DEBUG", False)
36+
37+
ALLOWED_HOSTS = ['*']
38+
39+
# Tuple of people who get error notifications
40+
ADMINS = [
41+
('Tapasweni Pathak', '[email protected]'),
42+
('Nikhita Raghunath', '[email protected]'),
43+
('Ibrahim Jarif', '[email protected]'),
44+
('Amar Prakash Pandey', '[email protected]')
45+
]
46+
47+
# Application definition
48+
49+
INSTALLED_APPS = (
50+
'main',
51+
'django.contrib.admin',
52+
'django.contrib.auth',
53+
'django.contrib.contenttypes',
54+
'django.contrib.sessions',
55+
'django.contrib.messages',
56+
'django.contrib.staticfiles',
57+
)
58+
59+
MIDDLEWARE_CLASSES = (
60+
'whitenoise.middleware.WhiteNoiseMiddleware',
61+
'django.contrib.sessions.middleware.SessionMiddleware',
62+
'django.middleware.common.CommonMiddleware',
63+
'django.middleware.csrf.CsrfViewMiddleware',
64+
'django.contrib.auth.middleware.AuthenticationMiddleware',
65+
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
66+
'django.contrib.messages.middleware.MessageMiddleware',
67+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
68+
)
69+
70+
ROOT_URLCONF = 'oshc.urls'
71+
72+
WSGI_APPLICATION = 'oshc.wsgi.application'
73+
74+
TEMPLATES = [
75+
{
76+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
77+
'APP_DIRS': True,
78+
'OPTIONS': {
79+
'context_processors': [
80+
'django.template.context_processors.debug',
81+
'django.template.context_processors.request',
82+
'django.contrib.auth.context_processors.auth',
83+
'django.contrib.messages.context_processors.messages',
84+
],
85+
},
86+
},
87+
]
88+
89+
# Database
90+
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases
91+
92+
DATABASES = {
93+
'default': {
94+
'ENGINE': 'django.db.backends.sqlite3',
95+
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
96+
}
97+
}
98+
99+
# Get DATABASE_URL environment variable and update default DATABASE settings
100+
# This setting is required for Heroku
101+
db_from_env = dj_database_url.config()
102+
DATABASES['default'].update(db_from_env)
103+
104+
# Internationalization
105+
# https://docs.djangoproject.com/en/1.7/topics/i18n/
106+
107+
LANGUAGE_CODE = 'en-us'
108+
109+
TIME_ZONE = 'UTC'
110+
111+
USE_I18N = True
112+
113+
USE_L10N = True
114+
115+
USE_TZ = True
116+
117+
# Simplified static file serving.
118+
# https://warehouse.python.org/project/whitenoise/
119+
120+
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
121+
122+
# Static files (CSS, JavaScript, Images)
123+
# https://docs.djangoproject.com/en/1.7/howto/static-files/
124+
125+
STATIC_URL = '/static/'
126+
PROJECT_PATH = os.path.dirname(os.path.abspath(__file__))
127+
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
128+
129+
STATICFILES_DIRS = (
130+
os.path.join(BASE_DIR, 'main/'),
131+
)

Diff for: oshc/oshc/settings/dev.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# dev settings
2+
from .base import *
3+
4+
5+
DEBUG = os.getenv("DEBUG", False)

Diff for: oshc/oshc/settings/predev.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# predev settings
2+
from .base import *
3+
4+
5+
DEBUG = os.getenv("DEBUG", True)

Diff for: oshc/oshc/settings/production.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# production settings
2+
from .base import *
3+
4+
5+
DEBUG = os.getenv("DEBUG", False)

0 commit comments

Comments
 (0)