This repository has been archived by the owner on Jan 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 329
/
default.py
302 lines (253 loc) · 8.03 KB
/
default.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
# -*- coding: utf-8 -*-
# Django settings for the mozillians project.
import logging
import sys
from funfactory.manage import path
from funfactory import settings_base as base
from settings import initial as pre
from settings import MEDIA_URL
from apps.users.helpers import calculate_username
from django.utils.functional import lazy
## Log settings
SYSLOG_TAG = "http_app_mozillians"
LOGGING = {
'loggers': {
'landing': {'level': logging.INFO},
'phonebook': {'level': logging.INFO},
},
}
## L10n
LOCALE_PATHS = [path('locale')]
# Accepted locales
PROD_LANGUAGES = ('ca', 'cs', 'de', 'en-US', 'es', 'hu', 'fr', 'ko', 'nl',
'pl', 'pt-BR', 'ru', 'sk', 'sl', 'sq', 'zh-TW', 'zh-CN',
'lt', 'ja')
# List of RTL locales known to this project. Subset of LANGUAGES.
RTL_LANGUAGES = () # ('ar', 'fa', 'fa-IR', 'he')
# For absoluate urls
PROTOCOL = "https://"
PORT = 443
## Media and templates.
TEMPLATE_DIRS = (path('apps/users/templates'), )
STATIC_ROOT = path('media/static')
STATIC_URL = MEDIA_URL + 'static/'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'jingo.Loader',
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
TEMPLATE_CONTEXT_PROCESSORS = (base.TEMPLATE_CONTEXT_PROCESSORS +
('django_browserid.context_processors.browserid_form',))
JINGO_EXCLUDE_APPS = [
'bootstrapform',
'admin',
]
DEFAULT_IMAGE_SRC = 'img/unknown.png'
MINIFY_BUNDLES = {
'css': {
'common': (
'css/bootstrap.css',
'css/jquery-ui-1.8.16.custom.css',
'js/libs/tag-it/css/jquery.tagit.css',
'css/base.css',
'css/bootstrap-responsive.css',
'css/base-480px.css',
'css/base-768px.css',
'css/base-980px.css',
),
'api': (
'css/prettify.css',
),
'test': (
'css/qunit.css',
),
'edit_profile': (
'css/user.css',
),
'register': (
'css/register.css',
),
},
'js': {
'common': (
'js/libs/jquery-1.7.2.js',
'js/libs/jquery-ui-1.8.7.custom.min.js',
'js/libs/bootstrap/bootstrap-transition.js',
'js/libs/bootstrap/bootstrap-alert.js',
'js/libs/bootstrap/bootstrap-modal.js',
'js/libs/bootstrap/bootstrap-dropdown.js',
'js/libs/bootstrap/bootstrap-tooltip.js',
'js/libs/bootstrap/bootstrap-popover.js',
'js/libs/bootstrap/bootstrap-button.js',
'js/libs/bootstrap/bootstrap-collapse.js',
'js/libs/bootstrap/bootstrap-carousel.js',
'js/libs/bootstrap/bootstrap-typeahead.js',
'js/libs/bootstrap/bootstrap-tab.js',
'js/libs/validation/validation.js',
'js/main.js',
'static/browserid/browserid.js',
'js/groups.js',
),
'api': (
'js/libs/prettify.js',
'js/api.js',
),
'edit_profile': (
'js/libs/tag-it/js/tag-it.js',
'js/profile_edit.js'
),
'register': (
'js/libs/tag-it/js/tag-it.js',
'js/register.js',
),
'search': (
'js/libs/jquery.endless-scroll.js',
'js/infinite.js',
'js/expand.js',
),
'backbone': (
'js/libs/underscore.js',
'js/libs/backbone.js',
'js/libs/backbone.localStorage.js',
'js/profiles.js',
),
'test': (
'js/libs/qunit.js',
'js/tests/test.js',
),
'profile_view': (
'js/profile_view.js',
),
}
}
MIDDLEWARE_CLASSES = list(base.MIDDLEWARE_CLASSES) + [
'commonware.response.middleware.StrictTransportMiddleware',
'csp.middleware.CSPMiddleware',
'django_statsd.middleware.GraphiteMiddleware',
'django_statsd.middleware.GraphiteRequestTimingMiddleware',
'django_statsd.middleware.TastyPieRequestTimingMiddleware',
'common.middleware.StrongholdMiddleware',
'common.middleware.UsernameRedirectionMiddleware',
'common.middleware.OldGroupRedirectionMiddleware',
'common.middleware.GroupAliasRedirectionMiddleware']
# StrictTransport
STS_SUBDOMAINS = True
# Not all URLs need locale.
SUPPORTED_NONLOCALES = list(base.SUPPORTED_NONLOCALES) + [
'csp',
'api',
'browserid',
'admin'
]
AUTHENTICATION_BACKENDS = ('common.backends.MozilliansBrowserID',)
# BrowserID creates a user if one doesn't exist.
BROWSERID_CREATE_USER = True
BROWSERID_USERNAME_ALGO = calculate_username
# On Login, we redirect through register.
LOGIN_REDIRECT_URL = '/register'
INSTALLED_APPS = list(base.INSTALLED_APPS) + [
# These need to go in order of migration.
'users',
'phonebook',
'groups',
'common',
'api',
'mozspaces',
'csp',
'jingo_minify',
'tower',
'cronjobs',
'elasticutils',
'sorl.thumbnail',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.staticfiles',
'django_browserid',
'bootstrapform',
# DB migrations
'south',
# re-assert dominance of 'django_nose'
'django_nose',
]
## Auth
PWD_ALGORITHM = 'bcrypt'
HMAC_KEYS = {
'2011-01-01': 'cheesecake',
}
SESSION_COOKIE_HTTPONLY = True
SESSION_ENGINE = "django.contrib.sessions.backends.signed_cookies"
ANON_ALWAYS = True
# Email
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
# Auth
LOGIN_URL = '/'
LOGIN_REDIRECT_URL = '/'
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '127.0.0.1:11211',
}
}
#: Userpics will be uploaded here.
USERPICS_PATH = pre.NETAPP_STORAGE + '/userpics'
# Django 1.4
# TODO fix all templates so this works.
# MEDIA_ROOT = pre.NETAPP_STORAGE
# Userpics will accessed here.
USERPICS_URL = pre.UPLOAD_URL + '/userpics'
AUTH_PROFILE_MODULE = 'users.UserProfile'
MAX_PHOTO_UPLOAD_SIZE = 8 * (1024 ** 2)
AUTO_VOUCH_DOMAINS = ('mozilla.com', 'mozilla.org', 'mozillafoundation.org')
SOUTH_TESTS_MIGRATE = False
# Django-CSP
CSP_IMG_SRC = ("'self'", 'http://www.google-analytics.com',
'https://ssl.google-analytics.com',
'http://www.gravatar.com',
'https://i1.wp.com',
'https://secure.gravatar.com',)
CSP_SCRIPT_SRC = ("'self'", 'http://www.google-analytics.com',
'https://ssl.google-analytics.com',
'https://www.google-analytics.com',
'https://browserid.org',
'https://login.persona.org',)
CSP_FRAME_SRC = ("'self'", 'https://browserid.org',
'https://login.persona.org',)
CSP_FONT_SRC = ("'self'", 'https://www.mozilla.org')
CSP_REPORT_ONLY = True
CSP_REPORT_URI = '/csp/report/'
ES_DISABLED = True
ES_HOSTS = ['127.0.0.1:9200']
ES_INDEXES = dict(default='mozillians')
ES_INDEXING_TIMEOUT = 10
# Sorl settings
THUMBNAIL_DUMMY = True
THUMBNAIL_PREFIX = 'uploads/sorl-cache/'
# This is for the commons/helper.py thumbnail.
DEFAULT_IMAGE_SRC = path('./media/uploads/unknown.png')
# Statsd Graphite
STATSD_CLIENT = 'django_statsd.clients.normal'
# Basket
# If we're running tests, don't hit the real basket server.
if 'test' in sys.argv:
BASKET_URL = 'http://127.0.0.1'
else:
BASKET_URL = 'http://basket.mozilla.com'
BASKET_NEWSLETTER = 'mozilla-phone'
USER_AVATAR_DIR = 'uploads/userprofile'
MOZSPACE_PHOTO_DIR = 'uploads/mozspaces'
# Google Analytics
GA_ACCOUNT_CODE = 'UA-35433268-19'
# Set ALLOWED_HOSTS based on SITE_URL.
def _allowed_hosts():
from django.conf import settings
from urlparse import urlparse
host = urlparse(settings.SITE_URL).netloc # Remove protocol and path
host = host.rsplit(':', 1)[0] # Remove port
return [host]
ALLOWED_HOSTS = lazy(_allowed_hosts, list)()
STRONGHOLD_EXCEPTIONS = ['^%s' % MEDIA_URL,
'^/admin/',
'^/browserid/verify/',
'^/api']