settings.py
8.2 KB
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
"""
Django settings for colab 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/
"""
BROKER_URL = 'redis://localhost:6379/0'
CELERY_RESULT_BACKEND = 'redis://localhost:6379/0'
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(__file__)
# Used for settings translation
from django.utils.translation import ugettext_lazy as _
# 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 = ""
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATE_DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# First app to provide AUTH_USER_MODEL to others
'colab.accounts',
# Not standard apps
'haystack',
'hitcounter',
'taggit',
# Own apps
'colab',
'colab.home',
'colab.plugins',
'colab.super_archives',
'colab.rss',
'colab.search',
'colab.tz',
'colab.utils',
'colab.signals',
)
ROOT_URLCONF = 'colab.urls'
WSGI_APPLICATION = 'colab.wsgi.application'
# Internationalization
# https://docs.djangoproject.com/en/1.7/topics/i18n/
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/
STATIC_ROOT = '/var/lib/colab/static/'
STATIC_URL = '/static/'
STATICFILES_STORAGE = \
'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'
# Normally you should not import ANYTHING from Django directly
# into your settings, but ImproperlyConfigured is an exception.
from django.core.exceptions import ImproperlyConfigured
def get_env_setting(setting):
""" Get the environment setting or return exception """
try:
return os.environ[setting]
except KeyError:
error_msg = "Set the %s env variable" % setting
raise ImproperlyConfigured(error_msg)
# Allow Django runserver to serve SVG files
# https://code.djangoproject.com/ticket/20162
import mimetypes
mimetypes.add_type('image/svg+xml', '.svg')
LANGUAGES = (
('en', _('English')),
('pt-br', _('Portuguese')),
('es', _('Spanish')),
)
DJANGO_DATE_FORMAT_TO_JS = {
'pt-br': ('pt-BR', 'dd/MM/yyyy'),
'es': ('es', 'dd/MM/yyyy'),
}
LANGUAGE_CODE = 'en'
# The absolute path to the folder containing the attachments
ATTACHMENTS_FOLDER_PATH = '/mnt/trac/attachments/'
# ORDERING_DATA receives the options to order for as it's keys and a dict as
# value, if you want to order for the last name, you can use something like:
# 'last_name': {'name': 'Last Name', 'fields': 'last_name'} inside the dict,
# you pass two major keys (name, fields)
# The major key name is the name to appear on the template
# the major key fields it show receive the name of the fields to order for in
# the indexes
ORDERING_DATA = {
'latest': {
'name': _(u'Recent activity'),
'fields': ('-modified', '-created'),
},
'hottest': {
'name': _(u'Relevance'),
'fields': None,
},
'type': {
'name': _(u'Type'),
'fields': ('type',),
}
}
# File type groupings is a tuple of tuples containg what it should filter,
# how it should be displayed, and a tuple of which mimetypes it includes
FILE_TYPE_GROUPINGS = (
('document', _(u'Document'),
('doc', 'docx', 'odt', 'otx', 'dotx', 'pdf', 'ott')),
('presentation', _(u'Presentation'), ('ppt', 'pptx', 'odp')),
('text', _(u'Text'), ('txt', 'po', 'conf', 'log')),
('code', _(u'Code'),
('py', 'php', 'js', 'sql', 'sh', 'patch', 'diff', 'html', '')),
('compressed', _(u'Compressed'), ('rar', 'zip', 'gz', 'tgz', 'bz2')),
('image', _(u'Image'),
('jpg', 'jpeg', 'png', 'tiff', 'gif', 'svg', 'psd', 'planner', 'cdr')),
('spreadsheet', _(u'Spreadsheet'),
('ods', 'xls', 'xlsx', 'xslt', 'csv')),
)
# the following variable define how many characters should be shown before
# a highlighted word, to make sure that the highlighted word will appear
HIGHLIGHT_NUM_CHARS_BEFORE_MATCH = 30
HAYSTACK_CUSTOM_HIGHLIGHTER = 'colab.utils.highlighting.ColabHighlighter'
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
'PATH': os.path.join(BASE_DIR, 'whoosh_index'),
}
}
DEFAULT_DATABASE = os.path.join(BASE_DIR, 'colab.sqlite3')
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': DEFAULT_DATABASE,
}
}
DATABASE_ROUTERS = []
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.static',
'django.core.context_processors.tz',
'django.contrib.messages.context_processors.messages',
'django.core.context_processors.request',
'colab.super_archives.context_processors.mailarchive',
'colab.plugins.context_processors.colab_apps',
'colab.home.context_processors.robots',
'colab.home.context_processors.ribbon',
'colab.home.context_processors.google_analytics',
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'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',
'colab.tz.middleware.TimezoneMiddleware',
)
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
)
LOCALE_PATHS = (
os.path.join(BASE_DIR, 'locale'),
os.path.join(BASE_DIR, 'super_archives/locale'),
)
AUTH_USER_MODEL = 'accounts.User'
from django.contrib.messages import constants as messages
MESSAGE_TAGS = {
messages.INFO: 'alert-info',
messages.SUCCESS: 'alert-success',
messages.WARNING: 'alert-warning',
messages.ERROR: 'alert-danger',
}
# Colab Settings
COLAB_HOME_URL = '/dashboard'
# Super Archives
SUPER_ARCHIVES_PATH = '/var/lib/mailman/archives/private'
SUPER_ARCHIVES_EXCLUDE = []
SUPER_ARCHIVES_LOCK_FILE = '/var/lock/colab/import_emails.lock'
# Mailman API settings
MAILMAN_API_URL = 'http://localhost:8124/v2/'
LOGIN_URL = '/account/login'
LOGOUT_URL = '/account/logout'
LOGIN_REDIRECT_URL = '/'
REVPROXY_ADD_REMOTE_USER = True
# Tastypie settings
TASTYPIE_DEFAULT_FORMATS = ['json', ]
from .utils import conf
SOCIAL_NETWORK_ENABLED = locals().get('SOCIAL_NETWORK_ENABLED') or False
locals().update(conf.load_py_settings())
locals().update(conf.load_colab_apps())
COLAB_APPS = locals().get('COLAB_APPS') or {}
for app_name, app in COLAB_APPS.items():
if 'dependencies' in app:
for dep in app.get('dependencies'):
if dep not in INSTALLED_APPS:
INSTALLED_APPS += (dep,)
if app.get('name') not in INSTALLED_APPS:
INSTALLED_APPS += (app.get('name'),)
if 'middlewares' in app:
for middleware in app.get('middlewares'):
if middleware not in MIDDLEWARE_CLASSES:
MIDDLEWARE_CLASSES += (middleware,)
if 'context_processors' in app:
for context_processor in app.get('context_processors'):
if context_processor not in TEMPLATE_CONTEXT_PROCESSORS:
TEMPLATE_CONTEXT_PROCESSORS += (context_processor,)
colab_templates = locals().get('COLAB_TEMPLATES') or ()
colab_statics = locals().get('COLAB_STATICS') or []
TEMPLATE_DIRS = tuple(colab_templates)
STATICFILES_DIRS = list(colab_statics)
STATICFILES_DIRS += [
os.path.join(BASE_DIR, 'static'),
]
TEMPLATE_DIRS += (
os.path.join(BASE_DIR, 'templates'),
)
conf.validate_database(DATABASES, DEFAULT_DATABASE, DEBUG)