ore.settings   A
last analyzed

Complexity

Total Complexity 0

Size/Duplication

Total Lines 237
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 0
eloc 194
dl 0
loc 237
rs 10
c 0
b 0
f 0
1
from configurations import Configuration, values
2
import os.path
3
4
5
class Common(Configuration):
6
    BACKEND_DAEMON = values.Value(
7
        'http://back:8000', environ_prefix='ORE')
8
    DATABASES = {
9
        'default': {
10
            'ENGINE': 'django.db.backends.postgresql_psycopg2',
11
            'NAME': values.Value('ore', environ_name='DB_NAME', environ_prefix='ORE'),
12
            'USER': values.Value('ore', environ_name='DB_USER', environ_prefix='ORE'),
13
            'PASSWORD': values.Value('ore', environ_name='DB_PASSWORD', environ_prefix='ORE'),
14
            'HOST': values.Value('localhost', environ_name='DB_HOST', environ_prefix='ORE'),
15
            'PORT': values.Value('', environ_name='DB_PORT', environ_prefix='ORE'),
16
        }
17
    }
18
    # Environment variable "SERVER" contains the host name of the server
19
    ALLOWED_HOSTS = ['localhost', '127.0.0.1', values.Value(
20
        'xxx', environ_prefix='ORE', environ_name='SERVER')]
21
    # Environment variable "SERVER_URL" contains the full URL for the server
22
    SERVER = str(values.Value(
23
        'xxx', environ_prefix='ORE', environ_name='SERVER_URL'))
24
    FEEDBACK_PAGE = values.URLValue(
25
        'https://groups.google.com/forum/#!forum/ore-support', environ_prefix='ORE')
26
    TERMS_PAGE = values.Value('/about/', environ_prefix='ORE')
27
    PRIVACY_PAGE = values.Value('/privacy/', environ_prefix='ORE')
28
    AUTH_PROFILE_MODULE = 'ore.UserProfile'
29
    CORS_ORIGIN_ALLOW_ALL = True
30
    EMAIL_HOST = 'localhost'
31
    EMAIL_SUBJECT_PREFIX = '[ORE] '
32
    LANGUAGE_CODE = 'en-en'
33
    LOGIN_REDIRECT_URL = '/projects/'
34
    LOGIN_URL = '/'
35
    REQUIRE_BASE_URL = 'script'
36
    REQUIRE_BUILD_PROFILE = '../lib/requirejs/require_build_profile.js'
37
    REQUIRE_JS = '../lib/requirejs/require-jquery.js'
38
    ROOT_URLCONF = 'ore.urls'
39
    MEDIA_ROOT = ''
40
    MEDIA_URL = ''
41
    USE_X_FORWARDED_HOST = True
42
    SEND_BROKEN_LINK_EMAILS = False
43
    SERVER_EMAIL = values.Value('NOT_SET', environ_prefix='ORE')
44
    SITE_ID = 1
45
    SOCIAL_AUTH_URL_NAMESPACE = 'social'
46
    SOCIAL_AUTH_FIELDS_STORED_IN_SESSION = ['next', ]
47
    SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = values.Value(
48
        'NOT_SET', environ_prefix='ORE')
49
    SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = values.Value(
50
        'NOT_SET', environ_prefix='ORE')
51
    SOCIAL_AUTH_TWITTER_KEY = values.Value('NOT_SET', environ_prefix='ORE')
52
    SOCIAL_AUTH_TWITTER_SECRET = values.Value(
53
        'NOT_SET', environ_prefix='ORE')
54
    SOCIAL_AUTH_LIVE_CLIENT_ID = values.Value(
55
        'NOT_SET', environ_prefix='ORE')
56
    SOCIAL_AUTH_LIVE_CLIENT_SECRET = values.Value(
57
        'NOT_SET', environ_prefix='ORE')
58
    SOCIAL_AUTH_YAHOO_OAUTH2_KEY = values.Value(
59
        'NOT_SET', environ_prefix='ORE')
60
    SOCIAL_AUTH_YAHOO_OAUTH2_SECRET = values.Value(
61
        'NOT_SET', environ_prefix='ORE')
62
    SOCIAL_AUTH_GITHUB_KEY = values.Value('NOT_SET', environ_prefix='ORE')
63
    SOCIAL_AUTH_GITHUB_SECRET = values.Value(
64
        'NOT_SET', environ_prefix='ORE')
65
    SOCIAL_AUTH_PIPELINE = (
66
        'social.pipeline.social_auth.social_details',
67
        'social.pipeline.social_auth.social_uid',
68
        'social.pipeline.social_auth.auth_allowed',
69
        'social.pipeline.social_auth.social_user',
70
        'social.pipeline.user.get_username',
71
        # Transition to 0.7.0 installation for existing users
72
        'social.pipeline.social_auth.associate_by_email',
73
        'social.pipeline.user.create_user',
74
        'social.pipeline.social_auth.associate_user',
75
        'social.pipeline.social_auth.load_extra_data',
76
        'social.pipeline.user.user_details'
77
    )
78
79
    STATICFILES_DIRS = ('ore/static',)
80
    STATICFILES_STORAGE = 'require.storage.OptimizedStaticFilesStorage'
81
    STATIC_ROOT = 'ore/static-release/'
82
    STATIC_URL = '/static/'
83
    TEST_RUNNER = 'django.test.runner.DiscoverRunner'
84
    TIME_ZONE = 'UTC'      # setting this to None doesn't work on fresh Linux systems
85
    USE_I18N = False
86
    USE_L10N = True
87
    USE_TZ = False
88
    WSGI_APPLICATION = 'ore.wsgi.application'
89
    ROBOTS_USE_SITEMAP = False
90
91
    STATICFILES_FINDERS = (
92
        'django.contrib.staticfiles.finders.FileSystemFinder',
93
        'django.contrib.staticfiles.finders.AppDirectoriesFinder',
94
    )
95
96
    TEMPLATE_LOADERS = (
97
        'django.template.loaders.filesystem.Loader',
98
        'django.template.loaders.app_directories.Loader',
99
    )
100
101
    TEMPLATE_CONTEXT_PROCESSORS = (
102
        'django.template.context_processors.debug',
103
        'django.core.context_processors.static',
104
        'django.contrib.auth.context_processors.auth',
105
        'django.contrib.messages.context_processors.messages',
106
        'social.apps.django_app.context_processors.backends',
107
        'social.apps.django_app.context_processors.login_redirect'
108
    )
109
110
    MIDDLEWARE_CLASSES = (
111
        'django.middleware.common.CommonMiddleware',
112
        'django.contrib.sessions.middleware.SessionMiddleware',
113
        'django.middleware.csrf.CsrfViewMiddleware',
114
        'django.contrib.auth.middleware.AuthenticationMiddleware',
115
        'django.contrib.messages.middleware.MessageMiddleware',
116
        'ore.middleware.HttpErrorMiddleware',
117
    )
118
119
    INSTALLED_APPS = (
120
        'django.contrib.auth',
121
        'django.contrib.contenttypes',
122
        'django.contrib.sessions',
123
        'django.contrib.messages',
124
        'django.contrib.staticfiles',
125
        'django.contrib.admin',
126
        'django.contrib.admindocs',
127
        'django.contrib.sites',
128
        'robots',
129
        'require',
130
        'social.apps.django_app.default',
131
        'tastypie',
132
        'ore'
133
    )
134
135
    AUTHENTICATION_BACKENDS = (
136
        'django.contrib.auth.backends.ModelBackend',
137
        'social.backends.google.GoogleOAuth2',
138
        'social.backends.twitter.TwitterOAuth',
139
        'social.backends.yahoo.YahooOAuth2',
140
        'social.backends.open_id.OpenIdAuth',
141
        'social.backends.live.LiveOAuth2',
142
        'social.backends.github.GithubOAuth2'
143
    )
144
145
    LOGGING = {
146
        'version': 1,
147
        'disable_existing_loggers': False,
148
        'filters': {
149
            'require_debug_false': {
150
                '()': 'django.utils.log.RequireDebugFalse'
151
            },
152
            'require_debug_true': {
153
                '()': 'django.utils.log.RequireDebugTrue'
154
            },
155
        },
156
        'formatters': {
157
            'verbose': {
158
                'format': "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s"
159
            },
160
            'simple': {
161
                'format': '%(levelname)s %(message)s'
162
            },
163
        },
164
        'handlers': {
165
            'console': {
166
                'level': 'DEBUG',
167
                'filters': ['require_debug_true'],
168
                'class': 'logging.StreamHandler'
169
            },
170
            'mail_admins': {
171
                'level': 'ERROR',
172
                'class': 'django.utils.log.AdminEmailHandler',
173
                'filters': ['require_debug_false'],
174
            },
175
            'False': {
176
                'level': 'DEBUG',
177
                'class': 'logging.NullHandler',
178
            },
179
        },
180
        'loggers': {
181
            'django.request': {
182
                'handlers': ['mail_admins', 'console'],
183
                'level': 'ERROR',
184
                'propagate': True,
185
            },
186
            'ore': {
187
                'handlers': ['console', ],
188
                'level': 'DEBUG',
189
                'propagate': True,
190
            },
191
            'social': {
192
                'handlers': ['console', ],
193
                'level': 'DEBUG',
194
                'propagate': True,
195
            },
196
197
        }
198
    }
199
200
201
class Dev(Common):
202
    DEBUG = True
203
    TEMPLATE_DEBUG = True
204
    SECRET_KEY = "4711"
205
    EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
206
    TEMPLATE_DIRS = ('ore/templates',
207
                     'ore/static/img')
208
    FOOTER = 'ORE Development Team (Dev Server)'
209
    SOCIAL_AUTH_USERNAME_FORM_URL = '/'
210
    SOCIAL_AUTH_USERNAME_FORM_HTML = 'dev_login.html'
211
    AUTHENTICATION_BACKENDS = Common.AUTHENTICATION_BACKENDS + \
212
        ('social.backends.username.UsernameAuth',)
213
    LOGGING = Common.LOGGING
214
    LOGGING['loggers']['django.request']['handlers'] = ['console']
215
    LOGGING['loggers']['ore']['handlers'] = ['console']
216
    ADMINS = (('ORE Developer', str(values.Value(
217
        '[email protected]', environ_prefix='ORE', environ_name='ADMIN_EMAIL'))),)
218
219
220
class Production(Common):
221
    DEBUG = False
222
    TEMPLATE_DEBUG = False
223
    SECRET_KEY = values.SecretValue(environ_prefix='ORE')
224
    # EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
225
    EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
226
    ADMINS = ((str(values.Value(
227
        'xxx', environ_prefix='ORE', environ_name='ADMIN_NAME')),
228
        str(values.Value(
229
            'xxx', environ_prefix='ORE', environ_name='ADMIN_EMAIL'))),)
230
    PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
231
    TEMPLATE_DIRS = (PROJECT_ROOT + '/templates',
232
                     PROJECT_ROOT + '/static-release/img')
233
    LOGGING = Common.LOGGING
234
    LOGGING['loggers']['django.request']['handlers'] = ['mail_admins']
235
    LOGGING['loggers']['ore']['handlers'] = ['console']
236
    FOOTER = values.Value('ORE Development Team', environ_prefix='ORE')
237