Commit 2c7cd89992d4f6ce93aec561175faf86de35389c
1 parent
3dbf38eb
Exists in
master
and in
39 other branches
One settings.py to rule them all!
Showing
6 changed files
with
301 additions
and
511 deletions
Show diff stats
... | ... | @@ -0,0 +1,53 @@ |
1 | + | |
2 | +DEBUG: false | |
3 | +TEMPLATE_DEBUG: false | |
4 | + | |
5 | +ADMINS: &admin | |
6 | + - | |
7 | + - John Foo | |
8 | + - john@example.com | |
9 | + - | |
10 | + - Mary Bar | |
11 | + - mary@example.com | |
12 | + | |
13 | +MANAGERS: *admin | |
14 | + | |
15 | +COLAB_FROM_ADDRESS: '"Colab" <noreply@example.com>' | |
16 | +SERVER_EMAIL: '"Colab" <noreply@example.com>' | |
17 | + | |
18 | +EMAIL_HOST: localhost | |
19 | +EMAIL_PORT: 25 | |
20 | +EMAIL_SUBJECT_PREFIX: '[colab]' | |
21 | + | |
22 | +SECRET_KEY: '{{ secret_key }}' | |
23 | + | |
24 | +SITE_URL: 'http://www.example.com/' | |
25 | + | |
26 | +ALLOWED_HOSTS: | |
27 | + - example.com | |
28 | + - example.org | |
29 | + - example.net | |
30 | + | |
31 | +CONVERSEJS_ENABLED: false | |
32 | + | |
33 | +CONVERSEJS_AUTO_REGISTER: 'xmpp.example.com' | |
34 | + | |
35 | +DATABASES: | |
36 | + default: | |
37 | + ENGINE: django.db.backends.postgresql_psycopg2 | |
38 | + HOST: localhost | |
39 | + NAME: colab | |
40 | + USER: colab | |
41 | + PASSWORD: colab | |
42 | + | |
43 | +ROBOTS_NOINDEX: false | |
44 | + | |
45 | +# Set to false to disable | |
46 | +RAVEN_DSN: 'http://public:secret@example.com/1' | |
47 | + | |
48 | +PROXIED_APPS: | |
49 | + gitlab: | |
50 | + upstream: 'http://localhost:8090/gitlab/' | |
51 | + trac: | |
52 | + upstream: 'http://localhost:5000/trac/' | |
53 | + | ... | ... |
src/colab/custom_settings.py
... | ... | @@ -1,313 +0,0 @@ |
1 | -from settings import * | |
2 | -from django.utils.translation import ugettext_lazy as _ | |
3 | - | |
4 | -# Allow Django runserver to serve SVG files | |
5 | -# https://code.djangoproject.com/ticket/20162 | |
6 | -import mimetypes | |
7 | -mimetypes.add_type('image/svg+xml', '.svg') | |
8 | - | |
9 | -DEBUG = False | |
10 | - | |
11 | -TEMPLATE_DEBUG = False | |
12 | - | |
13 | -LANGUAGES = ( | |
14 | - ('en', _('English')), | |
15 | - ('pt-br', _('Portuguese')), | |
16 | - ('es', _('Spanish')), | |
17 | -) | |
18 | - | |
19 | -DJANGO_DATE_FORMAT_TO_JS = { | |
20 | - 'pt-br': ('pt-BR', 'dd/MM/yyyy'), | |
21 | - 'es': ('es', 'dd/MM/yyyy'), | |
22 | -} | |
23 | - | |
24 | -LANGUAGE_CODE = 'en' | |
25 | - | |
26 | -# The absolute path to the folder containing the attachments | |
27 | -ATTACHMENTS_FOLDER_PATH = '/mnt/trac/attachments/' | |
28 | - | |
29 | -# ORDERING_DATA receives the options to order for as it's keys and a dict as | |
30 | -# value, if you want to order for the last name, you can use something like: | |
31 | -# 'last_name': {'name': 'Last Name', 'fields': 'last_name'} inside the dict, | |
32 | -# you pass two major keys (name, fields) | |
33 | -# The major key name is the name to appear on the template | |
34 | -# the major key fields it show receive the name of the fields to order for in | |
35 | -# the indexes | |
36 | - | |
37 | -ORDERING_DATA = { | |
38 | - 'latest': { | |
39 | - 'name': _(u'Recent activity'), | |
40 | - 'fields': ('-modified', '-created'), | |
41 | - }, | |
42 | - 'hottest': { | |
43 | - 'name': _(u'Relevance'), | |
44 | - 'fields': None, | |
45 | - }, | |
46 | -} | |
47 | - | |
48 | -# File type groupings is a tuple of tuples containg what it should filter, | |
49 | -# how it should be displayed, and a tuple of which mimetypes it includes | |
50 | -FILE_TYPE_GROUPINGS = ( | |
51 | - ('document', _(u'Document'), | |
52 | - ('doc', 'docx', 'odt', 'otx', 'dotx', 'pdf', 'ott')), | |
53 | - ('presentation', _(u'Presentation'), ('ppt', 'pptx', 'odp')), | |
54 | - ('text', _(u'Text'), ('txt', 'po', 'conf', 'log')), | |
55 | - ('code', _(u'Code'), | |
56 | - ('py', 'php', 'js', 'sql', 'sh', 'patch', 'diff', 'html', '')), | |
57 | - ('compressed', _(u'Compressed'), ('rar', 'zip', 'gz', 'tgz', 'bz2')), | |
58 | - ('image', _(u'Image'), | |
59 | - ('jpg', 'jpeg', 'png', 'tiff', 'gif', 'svg', 'psd', 'planner', 'cdr')), | |
60 | - ('spreadsheet', _(u'Spreadsheet'), | |
61 | - ('ods', 'xls', 'xlsx', 'xslt', 'csv')), | |
62 | -) | |
63 | - | |
64 | - | |
65 | -# the following variable define how many characters should be shown before | |
66 | -# a highlighted word, to make sure that the highlighted word will appear | |
67 | -HIGHLIGHT_NUM_CHARS_BEFORE_MATCH = 30 | |
68 | -HAYSTACK_CUSTOM_HIGHLIGHTER = 'colab.utils.highlighting.ColabHighlighter' | |
69 | - | |
70 | -HAYSTACK_CONNECTIONS = { | |
71 | - 'default': { | |
72 | - 'ENGINE': 'haystack.backends.solr_backend.SolrEngine', | |
73 | - 'URL': os.environ.get('COLAB_SOLR_URL', 'http://localhost:8983/solr'), | |
74 | - } | |
75 | -} | |
76 | - | |
77 | -DATABASES = { | |
78 | - 'default': { | |
79 | - 'ENGINE': 'django.db.backends.postgresql_psycopg2', | |
80 | - 'NAME': 'colab', | |
81 | - 'USER': 'colab', | |
82 | - 'PASSWORD': os.environ.get('COLAB_DEFAULT_DB_PWD'), | |
83 | - 'HOST': os.environ.get('COLAB_DEFAULT_DB_HOST'), | |
84 | - }, | |
85 | -} | |
86 | - | |
87 | -CACHES = { | |
88 | - 'default': { | |
89 | - 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', | |
90 | - 'LOCATION': '127.0.0.1:11211', | |
91 | - } | |
92 | -} | |
93 | - | |
94 | -DATABASE_ROUTERS = [] | |
95 | - | |
96 | -INSTALLED_APPS += ( | |
97 | - # First app to provide AUTH_USER_MODEL to others | |
98 | - 'accounts', | |
99 | - | |
100 | - # Not standard apps | |
101 | - 'raven.contrib.django.raven_compat', | |
102 | - 'cliauth', | |
103 | - 'django_mobile', | |
104 | - 'django_browserid', | |
105 | - 'conversejs', | |
106 | - 'haystack', | |
107 | - 'hitcounter', | |
108 | - 'i18n_model', | |
109 | - 'mptt', | |
110 | - 'dpaste', | |
111 | - | |
112 | - # Own apps | |
113 | - 'super_archives', | |
114 | - 'api', | |
115 | - 'rss', | |
116 | - 'planet', | |
117 | - 'search', | |
118 | - 'badger', | |
119 | - 'tz', | |
120 | - | |
121 | - # Feedzilla and deps | |
122 | - 'feedzilla', | |
123 | - 'taggit', | |
124 | - 'common', | |
125 | -) | |
126 | - | |
127 | -LOGGING = { | |
128 | - 'version': 1, | |
129 | - 'disable_existing_loggers': False, | |
130 | - 'root': { | |
131 | - 'level': 'WARNING', | |
132 | - 'handlers': ['sentry', 'console'], | |
133 | - }, | |
134 | - 'formatters': { | |
135 | - 'verbose': { | |
136 | - 'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s', | |
137 | - }, | |
138 | - }, | |
139 | - 'filters': { | |
140 | - 'require_debug_false': { | |
141 | - '()': 'django.utils.log.RequireDebugFalse' | |
142 | - } | |
143 | - }, | |
144 | - 'handlers': { | |
145 | - 'mail_admins': { | |
146 | - 'level': 'ERROR', | |
147 | - 'class': 'django.utils.log.AdminEmailHandler', | |
148 | - 'include_html': True, | |
149 | - 'filters': ['require_debug_false'], | |
150 | - }, | |
151 | - 'sentry': { | |
152 | - 'level': 'ERROR', | |
153 | - 'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler', | |
154 | - }, | |
155 | - 'console': { | |
156 | - 'level': 'DEBUG', | |
157 | - 'class': 'logging.StreamHandler', | |
158 | - 'formatter': 'verbose' | |
159 | - } | |
160 | - }, | |
161 | - 'loggers': { | |
162 | - 'django.request': { | |
163 | - 'handlers': ['mail_admins', 'sentry'], | |
164 | - 'level': 'ERROR', | |
165 | - 'propagate': True, | |
166 | - }, | |
167 | - 'django.db.backends': { | |
168 | - 'level': 'ERROR', | |
169 | - 'handlers': ['sentry'], | |
170 | - 'propagate': False, | |
171 | - }, | |
172 | - 'raven': { | |
173 | - 'level': 'DEBUG', | |
174 | - 'handlers': ['console'], | |
175 | - 'propagate': False, | |
176 | - }, | |
177 | - 'sentry.errors': { | |
178 | - 'level': 'DEBUG', | |
179 | - 'handlers': ['console'], | |
180 | - 'propagate': False, | |
181 | - }, | |
182 | - 'django_browserid': { | |
183 | - 'handlers': ['sentry'], | |
184 | - 'level': 'WARNING', | |
185 | - 'propagate': False, | |
186 | - }, | |
187 | - 'conversejs': { | |
188 | - 'handlers': ['console'], | |
189 | - 'level': 'DEBUG', | |
190 | - 'propagate': False, | |
191 | - }, | |
192 | - } | |
193 | -} | |
194 | - | |
195 | -TEMPLATE_CONTEXT_PROCESSORS = ( | |
196 | - 'django.contrib.auth.context_processors.auth', | |
197 | - 'django.core.context_processors.debug', | |
198 | - 'django.core.context_processors.i18n', | |
199 | - 'django.core.context_processors.media', | |
200 | - 'django.core.context_processors.static', | |
201 | - 'django.core.context_processors.tz', | |
202 | - 'django.contrib.messages.context_processors.messages', | |
203 | - 'django.core.context_processors.request', | |
204 | - 'django_mobile.context_processors.is_mobile', | |
205 | - 'super_archives.context_processors.mailarchive', | |
206 | - 'proxy.context_processors.proxied_apps', | |
207 | - 'home.context_processors.robots', | |
208 | -) | |
209 | - | |
210 | -MIDDLEWARE_CLASSES = ( | |
211 | - 'django.contrib.sessions.middleware.SessionMiddleware', | |
212 | - 'django.middleware.locale.LocaleMiddleware', | |
213 | - 'django.middleware.common.CommonMiddleware', | |
214 | - 'django.middleware.csrf.CsrfViewMiddleware', | |
215 | - 'django.contrib.auth.middleware.AuthenticationMiddleware', | |
216 | - 'django.contrib.messages.middleware.MessageMiddleware', | |
217 | - 'django.middleware.clickjacking.XFrameOptionsMiddleware', | |
218 | - 'django_mobile.middleware.MobileDetectionMiddleware', | |
219 | - 'django_mobile.middleware.SetFlavourMiddleware', | |
220 | - 'tz.middleware.TimezoneMiddleware', | |
221 | -) | |
222 | - | |
223 | -# Add the django_browserid authentication backend. | |
224 | -AUTHENTICATION_BACKENDS = ( | |
225 | - 'django.contrib.auth.backends.ModelBackend', | |
226 | - 'accounts.auth.ColabBrowserIDBackend', | |
227 | -) | |
228 | - | |
229 | -STATICFILES_DIRS = ( | |
230 | - os.path.join(BASE_DIR, 'static'), | |
231 | -) | |
232 | - | |
233 | -STATIC_ROOT = '/usr/share/nginx/colab/static/' | |
234 | -MEDIA_ROOT = '/usr/share/nginx/colab/media/' | |
235 | - | |
236 | -TEMPLATE_DIRS = ( | |
237 | - os.path.join(BASE_DIR, 'templates'), | |
238 | -) | |
239 | - | |
240 | -LOCALE_PATHS = ( | |
241 | - os.path.join(BASE_DIR, 'locale'), | |
242 | -) | |
243 | - | |
244 | -AUTH_USER_MODEL = 'accounts.User' | |
245 | - | |
246 | -ALLOWED_HOSTS = [] | |
247 | - | |
248 | -from django.contrib.messages import constants as messages | |
249 | -MESSAGE_TAGS = { | |
250 | - messages.INFO: 'alert-info', | |
251 | - messages.SUCCESS: 'alert-success', | |
252 | - messages.WARNING: 'alert-warning', | |
253 | - messages.ERROR: 'alert-danger', | |
254 | -} | |
255 | - | |
256 | -### Feedzilla (planet) | |
257 | -from feedzilla.settings import * | |
258 | -FEEDZILLA_PAGE_SIZE = 5 | |
259 | -FEEDZILLA_SITE_TITLE = _(u'Planet Colab') | |
260 | -FEEDZILLA_SITE_DESCRIPTION = _(u'Colab blog aggregator') | |
261 | - | |
262 | - | |
263 | -### Mailman API settings | |
264 | -MAILMAN_API_URL = 'http://localhost:9000' | |
265 | - | |
266 | - | |
267 | -### BrowserID / Persona | |
268 | -SITE_URL = 'localhost:8000' | |
269 | -BROWSERID_AUDIENCES = [SITE_URL, SITE_URL.replace('https', 'http')] | |
270 | - | |
271 | - | |
272 | -LOGIN_URL = '/' | |
273 | -LOGIN_REDIRECT_URL = '/' | |
274 | -LOGIN_REDIRECT_URL_FAILURE = '/' | |
275 | -LOGOUT_REDIRECT_URL = '/user/logout' | |
276 | -BROWSERID_CREATE_USER = False | |
277 | - | |
278 | - | |
279 | -## Proxy settings | |
280 | -COLAB_CI_URL = 'localhost:9000/ci/' | |
281 | - | |
282 | -REVPROXY_ADD_REMOTE_USER = True | |
283 | - | |
284 | - | |
285 | -## Converse.js settings | |
286 | -# This URL must use SSL in order to keep chat sessions secure | |
287 | -CONVERSEJS_BOSH_SERVICE_URL = SITE_URL + '/http-bind' | |
288 | - | |
289 | -CONVERSEJS_ALLOW_CONTACT_REQUESTS = False | |
290 | -CONVERSEJS_SHOW_ONLY_ONLINE_USERS = True | |
291 | - | |
292 | - | |
293 | -# Tastypie settings | |
294 | -TASTYPIE_DEFAULT_FORMATS = ['json', ] | |
295 | - | |
296 | - | |
297 | -# Dpaste settings | |
298 | -DPASTE_EXPIRE_CHOICES = ( | |
299 | - ('onetime', _(u'One Time Snippet')), | |
300 | - (3600, _(u'In one hour')), | |
301 | - (3600 * 24 * 7, _(u'In one week')), | |
302 | - (3600 * 24 * 30, _(u'In one month')), | |
303 | - ('never', _(u'Never')), | |
304 | -) | |
305 | -DPASTE_EXPIRE_DEFAULT = DPASTE_EXPIRE_CHOICES[4][0] | |
306 | -DPASTE_DEFAULT_GIST_DESCRIPTION = 'Gist created from Colab DPaste' | |
307 | -DPASTE_DEFAULT_GIST_NAME = 'colab_paste' | |
308 | -DPASTE_LEXER_DEFAULT = 'text' | |
309 | - | |
310 | -try: | |
311 | - from local_settings import * | |
312 | -except ImportError: | |
313 | - pass |
src/colab/local_settings-dev.py
... | ... | @@ -1,61 +0,0 @@ |
1 | - | |
2 | -from custom_settings import * | |
3 | - | |
4 | -DEBUG = True | |
5 | -TEMPLATE_DEBUG = DEBUG | |
6 | - | |
7 | -ADMINS = ( | |
8 | -) | |
9 | - | |
10 | -MANAGERS = ADMINS | |
11 | - | |
12 | -EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' | |
13 | -#EMAIL_HOST = '' | |
14 | -#EMAIL_PORT = 587 | |
15 | -EMAIL_SUBJECT_PREFIX = '' | |
16 | - | |
17 | -# Make this unique, and don't share it with anybody. | |
18 | -SECRET_KEY = ')(jksdfhsjkadfhjkh234ns!8fqu-1186h$vuj' | |
19 | - | |
20 | -SITE_URL = 'http://localhost:8000' | |
21 | -BROWSERID_AUDIENCES = [SITE_URL, SITE_URL.replace('https', 'http')] | |
22 | - | |
23 | -ALLOWED_HOSTS = ['*'] | |
24 | - | |
25 | -INTERNAL_IPS = ('127.0.0.1', ) | |
26 | - | |
27 | -CONVERSEJS_BOSH_SERVICE_URL = 'http://localhost:5280/http-bind' | |
28 | - | |
29 | -DATABASES['default']['PASSWORD'] = 'colab' | |
30 | -DATABASES['default']['HOST'] = 'localhost' | |
31 | - | |
32 | -HAYSTACK_CONNECTIONS['default']['URL'] = 'http://localhost:8983/solr/' | |
33 | - | |
34 | -COLAB_TRAC_URL = 'http://localhost:5000/trac/' | |
35 | -COLAB_CI_URL = 'http://localhost:8080/ci/' | |
36 | -COLAB_GITLAB_URL = 'http://localhost:8090/gitlab/' | |
37 | -COLAB_REDMINE_URL = 'http://localhost:9080/redmine/' | |
38 | - | |
39 | - | |
40 | -CONVERSEJS_ENABLED = False | |
41 | - | |
42 | -DIAZO_THEME = SITE_URL | |
43 | - | |
44 | -ROBOTS_NOINDEX = True | |
45 | - | |
46 | - | |
47 | -### Trac Settings | |
48 | - | |
49 | -#INSTALLED_APPS += ( | |
50 | -# 'proxy.trac', | |
51 | -#) | |
52 | -# | |
53 | -#DATABASE_ROUTERS += ['proxy.trac.routers.TracRouter'] | |
54 | -# | |
55 | -#DATABASES['trac'] = { | |
56 | -# 'ENGINE': 'django.db.backends.postgresql_psycopg2', | |
57 | -# 'NAME': 'trac_colab', | |
58 | -# 'USER': 'colab', | |
59 | -# 'PASSWORD': 'colab', | |
60 | -# 'HOST': 'localhost', | |
61 | -#} |
src/colab/local_settings-homolog.py
... | ... | @@ -1,65 +0,0 @@ |
1 | - | |
2 | -import os | |
3 | -import json | |
4 | - | |
5 | -from custom_settings import * | |
6 | - | |
7 | -SECRETS_FILE = '/home/colab/colab/secrets.json' | |
8 | - | |
9 | -if os.path.exists(SECRETS_FILE): | |
10 | - secrets = json.load(file(SECRETS_FILE)) | |
11 | - | |
12 | - | |
13 | -DEBUG = False | |
14 | -TEMPLATE_DEBUG = DEBUG | |
15 | - | |
16 | -ADMINS = ( | |
17 | - ('Paulo Meirelles', 'paulo@softwarelivre.org'), | |
18 | -) | |
19 | - | |
20 | -MANAGERS = ADMINS | |
21 | - | |
22 | -COLAB_FROM_ADDRESS = '"Portal do Software Publico" <noreply@beta.softwarepublico.gov.br>' | |
23 | -SERVER_EMAIL = COLAB_FROM_ADDRESS | |
24 | -EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' | |
25 | -EMAIL_HOST = 'localhost' | |
26 | -EMAIL_PORT = 25 | |
27 | -EMAIL_SUBJECT_PREFIX = '' | |
28 | - | |
29 | -# Make this unique, and don't share it with anybody. | |
30 | -SECRET_KEY = secrets.get('SECRET_KEY') | |
31 | - | |
32 | -SITE_URL = 'http://beta.softwarepublico.gov.br' | |
33 | -BROWSERID_AUDIENCES = [SITE_URL, SITE_URL.replace('https', 'http')] | |
34 | - | |
35 | -ALLOWED_HOSTS = ['beta.softwarepublico.gov.br'] | |
36 | - | |
37 | -INTERNAL_IPS = ('127.0.0.1', ) | |
38 | - | |
39 | -DATABASES['default']['PASSWORD'] = secrets.get('COLAB_DB_PWD') | |
40 | -DATABASES['default']['HOST'] = 'localhost' | |
41 | - | |
42 | -TRAC_ENABLED = True | |
43 | - | |
44 | -if TRAC_ENABLED: | |
45 | - from trac_settings import * | |
46 | - DATABASES['trac'] = TRAC_DATABASE | |
47 | - DATABASES['trac']['PASSWORD'] = secrets.get('TRAC_DB_PWD') | |
48 | - DATABASES['trac']['HOST'] = 'localhost' | |
49 | - | |
50 | -HAYSTACK_CONNECTIONS['default']['URL'] = 'http://localhost:8983/solr/' | |
51 | - | |
52 | -COLAB_TRAC_URL = 'http://localhost:5000/trac/' | |
53 | -COLAB_CI_URL = 'http://localhost:8080/ci/' | |
54 | -COLAB_GITLAB_URL = 'http://localhost:8090/gitlab/' | |
55 | -COLAB_REDMINE_URL = 'http://localhost:9080/redmine/' | |
56 | - | |
57 | -CONVERSEJS_ENABLED = False | |
58 | - | |
59 | -DIAZO_THEME = SITE_URL | |
60 | - | |
61 | -ROBOTS_NOINDEX = True | |
62 | - | |
63 | -RAVEN_CONFIG = { | |
64 | - 'dsn': secrets.get('RAVEN_DSN', '') + '?timeout=30', | |
65 | -} |
src/colab/local_settings-prod.py
... | ... | @@ -1,54 +0,0 @@ |
1 | - | |
2 | -import os | |
3 | -import json | |
4 | - | |
5 | -from custom_settings import * | |
6 | - | |
7 | -SECRETS_FILE = '/home/colab/colab/secrets.json' | |
8 | - | |
9 | -if os.path.exists(SECRETS_FILE): | |
10 | - secrets = json.load(file(SECRETS_FILE)) | |
11 | - | |
12 | -DEBUG = False | |
13 | -TEMPLATE_DEBUG = DEBUG | |
14 | - | |
15 | -ADMINS = ( | |
16 | - ('Name Surname', 'email@provider.com'), | |
17 | -) | |
18 | -MANAGERS = ADMINS | |
19 | - | |
20 | -COLAB_FROM_ADDRESS = '"Colab" <noreply@domain.com>' | |
21 | -SERVER_EMAIL = COLAB_FROM_ADDRESS | |
22 | -EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' | |
23 | -EMAIL_HOST = '' | |
24 | -EMAIL_PORT = 25 | |
25 | -EMAIL_SUBJECT_PREFIX = '' | |
26 | - | |
27 | -# Make this unique, and don't share it with anybody. | |
28 | -SECRET_KEY = secrets.get('SECRET_KEY') | |
29 | - | |
30 | -SITE_URL = '' | |
31 | -ALLOWED_HOSTS = [] | |
32 | - | |
33 | -# XMPP Server | |
34 | -CONVERSEJS_AUTO_REGISTER = '' | |
35 | - | |
36 | -DATABASES['default']['PASSWORD'] = secrets.get('COLAB_DB_PWD') | |
37 | -DATABASES['default']['HOST'] = 'localhost' | |
38 | - | |
39 | -DATABASES['trac'] = 'trac_colab' | |
40 | -DATABASES['trac']['PASSWORD'] = secrets.get('TRAC_DB_PWD') | |
41 | -DATABASES['trac']['HOST'] = 'localhost' | |
42 | - | |
43 | -HAYSTACK_CONNECTIONS['default']['URL'] = 'http://localhost:8983/solr/' | |
44 | - | |
45 | -COLAB_TRAC_URL = 'http://localhost:5000/trac/' | |
46 | -COLAB_GITLAB_URL = 'http://localhost:8090/gitlab/' | |
47 | - | |
48 | -CONVERSEJS_ENABLED = False | |
49 | - | |
50 | -ROBOTS_NOINDEX = False | |
51 | - | |
52 | -RAVEN_CONFIG = { | |
53 | - 'dsn': secrets.get('RAVEN_DSN', '') + '?timeout=30', | |
54 | -} |
src/colab/settings.py
... | ... | @@ -2,22 +2,24 @@ |
2 | 2 | Django settings for colab project. |
3 | 3 | |
4 | 4 | For more information on this file, see |
5 | -https://docs.djangoproject.com/en/dev/topics/settings/ | |
5 | +https://docs.djangoproject.com/en/1.7/topics/settings/ | |
6 | 6 | |
7 | 7 | For the full list of settings and their values, see |
8 | -https://docs.djangoproject.com/en/dev/ref/settings/ | |
8 | +https://docs.djangoproject.com/en/1.7/ref/settings/ | |
9 | 9 | """ |
10 | 10 | |
11 | 11 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) |
12 | 12 | import os |
13 | 13 | BASE_DIR = os.path.dirname(os.path.dirname(__file__)) |
14 | 14 | |
15 | +# Used for settings translation | |
16 | +from django.utils.translation import ugettext_lazy as _ | |
15 | 17 | |
16 | 18 | # Quick-start development settings - unsuitable for production |
17 | -# See https://docs.djangoproject.com/en/dev/howto/deployment/checklist/ | |
19 | +# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/ | |
18 | 20 | |
19 | 21 | # SECURITY WARNING: keep the secret key used in production secret! |
20 | -SECRET_KEY = 'd%gy$gfn4z2=z414qvqouyd2h6_i8nr_m4zmlxqklu15u!8&^@' | |
22 | +SECRET_KEY = "{{ secret_key }}" | |
21 | 23 | |
22 | 24 | # SECURITY WARNING: don't run with debug turned on in production! |
23 | 25 | DEBUG = True |
... | ... | @@ -26,6 +28,7 @@ TEMPLATE_DEBUG = True |
26 | 28 | |
27 | 29 | ALLOWED_HOSTS = [] |
28 | 30 | |
31 | +DATABASE_ROUTERS = [] | |
29 | 32 | |
30 | 33 | # Application definition |
31 | 34 | |
... | ... | @@ -36,6 +39,35 @@ INSTALLED_APPS = ( |
36 | 39 | 'django.contrib.sessions', |
37 | 40 | 'django.contrib.messages', |
38 | 41 | 'django.contrib.staticfiles', |
42 | + | |
43 | + # First app to provide AUTH_USER_MODEL to others | |
44 | + 'accounts', | |
45 | + | |
46 | + # Not standard apps | |
47 | + 'raven.contrib.django.raven_compat', | |
48 | + 'cliauth', | |
49 | + 'django_mobile', | |
50 | + 'django_browserid', | |
51 | + 'conversejs', | |
52 | + 'haystack', | |
53 | + 'hitcounter', | |
54 | + 'i18n_model', | |
55 | + 'mptt', | |
56 | + 'dpaste', | |
57 | + | |
58 | + # Own apps | |
59 | + 'super_archives', | |
60 | + 'api', | |
61 | + 'rss', | |
62 | + 'planet', | |
63 | + 'search', | |
64 | + 'badger', | |
65 | + 'tz', | |
66 | + | |
67 | + # Feedzilla and deps | |
68 | + 'feedzilla', | |
69 | + 'taggit', | |
70 | + 'common', | |
39 | 71 | ) |
40 | 72 | |
41 | 73 | MIDDLEWARE_CLASSES = ( |
... | ... | @@ -43,6 +75,7 @@ MIDDLEWARE_CLASSES = ( |
43 | 75 | 'django.middleware.common.CommonMiddleware', |
44 | 76 | 'django.middleware.csrf.CsrfViewMiddleware', |
45 | 77 | 'django.contrib.auth.middleware.AuthenticationMiddleware', |
78 | + 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', | |
46 | 79 | 'django.contrib.messages.middleware.MessageMiddleware', |
47 | 80 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', |
48 | 81 | ) |
... | ... | @@ -51,19 +84,8 @@ ROOT_URLCONF = 'colab.urls' |
51 | 84 | |
52 | 85 | WSGI_APPLICATION = 'colab.wsgi.application' |
53 | 86 | |
54 | - | |
55 | -# Database | |
56 | -# https://docs.djangoproject.com/en/dev/ref/settings/#databases | |
57 | - | |
58 | -DATABASES = { | |
59 | - 'default': { | |
60 | - 'ENGINE': 'django.db.backends.sqlite3', | |
61 | - 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), | |
62 | - } | |
63 | -} | |
64 | - | |
65 | 87 | # Internationalization |
66 | -# https://docs.djangoproject.com/en/dev/topics/i18n/ | |
88 | +# https://docs.djangoproject.com/en/1.7/topics/i18n/ | |
67 | 89 | |
68 | 90 | LANGUAGE_CODE = 'en-us' |
69 | 91 | |
... | ... | @@ -77,9 +99,217 @@ USE_TZ = True |
77 | 99 | |
78 | 100 | |
79 | 101 | # Static files (CSS, JavaScript, Images) |
80 | -# https://docs.djangoproject.com/en/dev/howto/static-files/ | |
102 | +# https://docs.djangoproject.com/en/1.7/howto/static-files/ | |
103 | + | |
104 | +STATIC_ROOT = '/usr/share/nginx/colab/static/' | |
105 | +MEDIA_ROOT = '/usr/share/nginx/colab/media/' | |
81 | 106 | |
82 | 107 | STATIC_URL = '/static/' |
83 | 108 | MEDIA_URL = '/media/' |
84 | 109 | |
85 | -from custom_settings import * | |
110 | + | |
111 | +# Normally you should not import ANYTHING from Django directly | |
112 | +# into your settings, but ImproperlyConfigured is an exception. | |
113 | +from django.core.exceptions import ImproperlyConfigured | |
114 | + | |
115 | + | |
116 | +def get_env_setting(setting): | |
117 | + """ Get the environment setting or return exception """ | |
118 | + try: | |
119 | + return os.environ[setting] | |
120 | + except KeyError: | |
121 | + error_msg = "Set the %s env variable" % setting | |
122 | + raise ImproperlyConfigured(error_msg) | |
123 | + | |
124 | + | |
125 | +# Allow Django runserver to serve SVG files | |
126 | +# https://code.djangoproject.com/ticket/20162 | |
127 | +import mimetypes | |
128 | +mimetypes.add_type('image/svg+xml', '.svg') | |
129 | + | |
130 | +LANGUAGES = ( | |
131 | + ('en', _('English')), | |
132 | + ('pt-br', _('Portuguese')), | |
133 | + ('es', _('Spanish')), | |
134 | +) | |
135 | + | |
136 | +DJANGO_DATE_FORMAT_TO_JS = { | |
137 | + 'pt-br': ('pt-BR', 'dd/MM/yyyy'), | |
138 | + 'es': ('es', 'dd/MM/yyyy'), | |
139 | +} | |
140 | + | |
141 | +LANGUAGE_CODE = 'en' | |
142 | + | |
143 | +# The absolute path to the folder containing the attachments | |
144 | +ATTACHMENTS_FOLDER_PATH = '/mnt/trac/attachments/' | |
145 | + | |
146 | +# ORDERING_DATA receives the options to order for as it's keys and a dict as | |
147 | +# value, if you want to order for the last name, you can use something like: | |
148 | +# 'last_name': {'name': 'Last Name', 'fields': 'last_name'} inside the dict, | |
149 | +# you pass two major keys (name, fields) | |
150 | +# The major key name is the name to appear on the template | |
151 | +# the major key fields it show receive the name of the fields to order for in | |
152 | +# the indexes | |
153 | + | |
154 | +ORDERING_DATA = { | |
155 | + 'latest': { | |
156 | + 'name': _(u'Recent activity'), | |
157 | + 'fields': ('-modified', '-created'), | |
158 | + }, | |
159 | + 'hottest': { | |
160 | + 'name': _(u'Relevance'), | |
161 | + 'fields': None, | |
162 | + }, | |
163 | +} | |
164 | + | |
165 | + | |
166 | +# File type groupings is a tuple of tuples containg what it should filter, | |
167 | +# how it should be displayed, and a tuple of which mimetypes it includes | |
168 | +FILE_TYPE_GROUPINGS = ( | |
169 | + ('document', _(u'Document'), | |
170 | + ('doc', 'docx', 'odt', 'otx', 'dotx', 'pdf', 'ott')), | |
171 | + ('presentation', _(u'Presentation'), ('ppt', 'pptx', 'odp')), | |
172 | + ('text', _(u'Text'), ('txt', 'po', 'conf', 'log')), | |
173 | + ('code', _(u'Code'), | |
174 | + ('py', 'php', 'js', 'sql', 'sh', 'patch', 'diff', 'html', '')), | |
175 | + ('compressed', _(u'Compressed'), ('rar', 'zip', 'gz', 'tgz', 'bz2')), | |
176 | + ('image', _(u'Image'), | |
177 | + ('jpg', 'jpeg', 'png', 'tiff', 'gif', 'svg', 'psd', 'planner', 'cdr')), | |
178 | + ('spreadsheet', _(u'Spreadsheet'), | |
179 | + ('ods', 'xls', 'xlsx', 'xslt', 'csv')), | |
180 | +) | |
181 | + | |
182 | +# the following variable define how many characters should be shown before | |
183 | +# a highlighted word, to make sure that the highlighted word will appear | |
184 | +HIGHLIGHT_NUM_CHARS_BEFORE_MATCH = 30 | |
185 | +HAYSTACK_CUSTOM_HIGHLIGHTER = 'colab.utils.highlighting.ColabHighlighter' | |
186 | + | |
187 | +HAYSTACK_CONNECTIONS = { | |
188 | + 'default': { | |
189 | + 'ENGINE': 'haystack.backends.solr_backend.SolrEngine', | |
190 | + 'URL': 'http://localhost:8983/solr/', | |
191 | + } | |
192 | +} | |
193 | + | |
194 | +CACHES = { | |
195 | + 'default': { | |
196 | + 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', | |
197 | + 'LOCATION': '127.0.0.1:11211', | |
198 | + } | |
199 | +} | |
200 | + | |
201 | +DATABASE_ROUTERS = [] | |
202 | + | |
203 | + | |
204 | +TEMPLATE_CONTEXT_PROCESSORS = ( | |
205 | + 'django.contrib.auth.context_processors.auth', | |
206 | + 'django.core.context_processors.debug', | |
207 | + 'django.core.context_processors.i18n', | |
208 | + 'django.core.context_processors.media', | |
209 | + 'django.core.context_processors.static', | |
210 | + 'django.core.context_processors.tz', | |
211 | + 'django.contrib.messages.context_processors.messages', | |
212 | + 'django.core.context_processors.request', | |
213 | + 'django_mobile.context_processors.is_mobile', | |
214 | + 'super_archives.context_processors.mailarchive', | |
215 | + 'proxy.context_processors.proxied_apps', | |
216 | + 'home.context_processors.robots', | |
217 | +) | |
218 | + | |
219 | +MIDDLEWARE_CLASSES = ( | |
220 | + 'django.contrib.sessions.middleware.SessionMiddleware', | |
221 | + 'django.middleware.locale.LocaleMiddleware', | |
222 | + 'django.middleware.common.CommonMiddleware', | |
223 | + 'django.middleware.csrf.CsrfViewMiddleware', | |
224 | + 'django.contrib.auth.middleware.AuthenticationMiddleware', | |
225 | + 'django.contrib.messages.middleware.MessageMiddleware', | |
226 | + 'django.middleware.clickjacking.XFrameOptionsMiddleware', | |
227 | + 'django_mobile.middleware.MobileDetectionMiddleware', | |
228 | + 'django_mobile.middleware.SetFlavourMiddleware', | |
229 | + 'tz.middleware.TimezoneMiddleware', | |
230 | +) | |
231 | + | |
232 | +# Add the django_browserid authentication backend. | |
233 | +AUTHENTICATION_BACKENDS = ( | |
234 | + 'django.contrib.auth.backends.ModelBackend', | |
235 | + 'accounts.auth.ColabBrowserIDBackend', | |
236 | +) | |
237 | + | |
238 | +STATICFILES_DIRS = ( | |
239 | + os.path.join(BASE_DIR, 'static'), | |
240 | +) | |
241 | + | |
242 | +TEMPLATE_DIRS = ( | |
243 | + os.path.join(BASE_DIR, 'templates'), | |
244 | +) | |
245 | + | |
246 | +LOCALE_PATHS = ( | |
247 | + os.path.join(BASE_DIR, 'locale'), | |
248 | +) | |
249 | + | |
250 | +AUTH_USER_MODEL = 'accounts.User' | |
251 | + | |
252 | +from django.contrib.messages import constants as messages | |
253 | +MESSAGE_TAGS = { | |
254 | + messages.INFO: 'alert-info', | |
255 | + messages.SUCCESS: 'alert-success', | |
256 | + messages.WARNING: 'alert-warning', | |
257 | + messages.ERROR: 'alert-danger', | |
258 | +} | |
259 | + | |
260 | +### Feedzilla (planet) | |
261 | +from feedzilla.settings import * | |
262 | +FEEDZILLA_PAGE_SIZE = 5 | |
263 | +FEEDZILLA_SITE_TITLE = _(u'Planet Colab') | |
264 | +FEEDZILLA_SITE_DESCRIPTION = _(u'Colab blog aggregator') | |
265 | + | |
266 | +### Mailman API settings | |
267 | +MAILMAN_API_URL = 'http://localhost:9000' | |
268 | + | |
269 | +### BrowserID / Persona | |
270 | +SITE_URL = 'localhost:8000' | |
271 | +BROWSERID_AUDIENCES = [SITE_URL, SITE_URL.replace('https', 'http')] | |
272 | + | |
273 | + | |
274 | +LOGIN_URL = '/' | |
275 | +LOGIN_REDIRECT_URL = '/' | |
276 | +LOGIN_REDIRECT_URL_FAILURE = '/' | |
277 | +LOGOUT_REDIRECT_URL = '/user/logout' | |
278 | +BROWSERID_CREATE_USER = False | |
279 | + | |
280 | +REVPROXY_ADD_REMOTE_USER = True | |
281 | + | |
282 | +## Converse.js settings | |
283 | +# This URL must use SSL in order to keep chat sessions secure | |
284 | +CONVERSEJS_BOSH_SERVICE_URL = SITE_URL + '/http-bind' | |
285 | + | |
286 | +CONVERSEJS_ALLOW_CONTACT_REQUESTS = False | |
287 | +CONVERSEJS_SHOW_ONLY_ONLINE_USERS = True | |
288 | + | |
289 | + | |
290 | +# Tastypie settings | |
291 | +TASTYPIE_DEFAULT_FORMATS = ['json', ] | |
292 | + | |
293 | +# Dpaste settings | |
294 | +DPASTE_EXPIRE_CHOICES = ( | |
295 | + ('onetime', _(u'One Time Snippet')), | |
296 | + (3600, _(u'In one hour')), | |
297 | + (3600 * 24 * 7, _(u'In one week')), | |
298 | + (3600 * 24 * 30, _(u'In one month')), | |
299 | + ('never', _(u'Never')), | |
300 | +) | |
301 | +DPASTE_EXPIRE_DEFAULT = DPASTE_EXPIRE_CHOICES[4][0] | |
302 | +DPASTE_DEFAULT_GIST_DESCRIPTION = 'Gist created from Colab DPaste' | |
303 | +DPASTE_DEFAULT_GIST_NAME = 'colab_paste' | |
304 | +DPASTE_LEXER_DEFAULT = 'text' | |
305 | + | |
306 | +from .utils.conf import load_yaml_settings | |
307 | +locals().update(load_yaml_settings()) | |
308 | + | |
309 | +if RAVEN_DSN: | |
310 | + RAVEN_CONFIG = { | |
311 | + 'dsn': RAVEN_DSN + '?timeout=30', | |
312 | + } | |
313 | + | |
314 | +for app_label in PROXIED_APPS.keys(): | |
315 | + INSTALLED_APPS += ('proxy.{}'.format(app_label),) | ... | ... |