forked from dimagi/commcare-hq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.py
executable file
·483 lines (408 loc) · 14.3 KB
/
settings.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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
#!/usr/bin/env python
# vim: ai ts=4 sts=4 et sw=4 encoding=utf-8
import os
import logging
from django.contrib import messages
CACHE_BACKEND = 'memcached://127.0.0.1:11211/'
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = ()
MANAGERS = ADMINS
# default to the system's timezone settings
TIME_ZONE = "UTC"
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# Django i18n searches for translation files (django.po) within this dir
LOCALE_PATHS=['contrib/locale']
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = ''
STATIC_ROOT = ''
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = '/media/'
STATIC_URL = '/static/'
filepath = os.path.abspath(os.path.dirname(__file__))
STATICFILES_FINDERS = (
"django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder"
)
STATICFILES_DIRS = (
('formdesigner', os.path.join(filepath,'submodules', 'formdesigner')),
)
DJANGO_LOG_FILE = "%s/%s" % (filepath, "commcarehq.django.log")
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/media/'
# Make this unique, and don't share it with anybody.
SECRET_KEY = '2rgmwtyq$thj49+-6u7x9t39r7jflu&1ljj3x2c0n0fl$)04_0'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
'django.template.loaders.eggs.Loader',
# 'django.template.loaders.eggs.load_template_source',
)
MIDDLEWARE_CLASSES = [
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'corehq.middleware.OpenRosaMiddleware',
'corehq.apps.domain.middleware.DomainMiddleware',
'corehq.apps.users.middleware.UsersMiddleware',
'casexml.apps.phone.middleware.SyncTokenMiddleware',
'auditcare.middleware.AuditMiddleware',
]
ROOT_URLCONF = "urls"
TEMPLATE_CONTEXT_PROCESSORS = [
"django.core.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.request",
"django.contrib.messages.context_processors.messages",
'django.core.context_processors.static',
"corehq.util.context_processors.base_template", # sticks the base template inside all responses
"corehq.util.context_processors.google_analytics",
]
TEMPLATE_DIRS = [
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
]
DEFAULT_APPS = (
'corehq.apps.userhack', # this has to be above auth
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
#'django.contrib.messages', # don't need this for messages and it's causing some error
'django.contrib.staticfiles',
'south',
'djcelery', # pip install django-celery
'djtables', # pip install djtables
#'ghettoq', # pip install ghettoq
'djkombu', # pip install django-kombu
'couchdbkit.ext.django',
)
HQ_APPS = (
'django_digest',
'django_rest_interface',
'django_granular_permissions',
'django_tables',
'django_user_registration',
'auditcare',
'djangocouch',
'djangocouchuser',
'hqscripts',
'casexml.apps.case',
'casexml.apps.phone',
'corehq.apps.cleanup',
'corehq.apps.cloudcare',
'corehq.apps.domain',
'corehq.apps.domainsync',
'corehq.apps.hqadmin',
'corehq.apps.hqcase',
'corehq.apps.hqwebapp',
'corehq.apps.docs',
'corehq.apps.hqmedia',
'couchforms',
'couchexport',
'couchlog',
'formtranslate',
'receiver',
'langcodes',
'corehq.apps.receiverwrapper',
'corehq.apps.migration',
'corehq.apps.app_manager',
'corehq.apps.fixtures',
'corehq.apps.reminders',
'corehq.apps.prescriptions',
'corehq.apps.translations',
'corehq.apps.users',
'corehq.apps.settings',
'corehq.apps.ota',
'corehq.apps.groups',
'corehq.apps.sms',
'corehq.apps.registration',
'corehq.apps.unicel',
'corehq.apps.reports',
'corehq.apps.hq-bootstrap',
'corehq.apps.builds',
'corehq.apps.api',
'corehq.couchapps',
'sofabed.forms',
'soil',
'corehq.apps.hqsofabed',
'xep_hq_server',
'touchforms.formplayer',
'phonelog',
'pathfinder',
'hutch',
'dca',
'loadtest',
)
REFLEXIVE_URL_BASE = "localhost:8000"
INSTALLED_APPS = DEFAULT_APPS + HQ_APPS
TABS = [
("corehq.apps.reports.views.default", "Reports"),
("corehq.apps.app_manager.views.default", "Applications"),
("corehq.apps.sms.views.messaging", "Messages"),
("corehq.apps.settings.views.default", "Settings & Users"),
("corehq.apps.hqadmin.views.default", "Admin Reports", "is_superuser"),
]
# after login, django redirects to this URL
# rather than the default 'accounts/profile'
LOGIN_REDIRECT_URL='/'
####### Domain settings #######
DOMAIN_MAX_REGISTRATION_REQUESTS_PER_DAY=99
DOMAIN_SELECT_URL="/domain/select/"
LOGIN_URL="/accounts/login/"
# For the registration app
# One week to confirm a registered user account
ACCOUNT_ACTIVATION_DAYS=7
# If a user tries to access domain admin pages but isn't a domain
# administrator, here's where he/she is redirected
DOMAIN_NOT_ADMIN_REDIRECT_PAGE_NAME="homepage"
# domain syncs
# e.g.
# { sourcedomain1: { "domain": targetdomain1,
# "transform": path.to.transformfunction1 },
# sourcedomain2: {...} }
DOMAIN_SYNCS = { }
# if you want to deidentify app names, put a dictionary in your settings
# of source names to deidentified names
DOMAIN_SYNC_APP_NAME_MAP = {}
DOMAIN_SYNC_DATABASE_NAME = "commcarehq-public"
####### Release Manager App settings #######
RELEASE_FILE_PATH=os.path.join("data","builds")
## soil heartbead config ##
SOIL_HEARTBEAT_CACHE_KEY = "django-soil-heartbeat"
####### Shared/Global/UI Settings ######
# restyle some templates
BASE_TEMPLATE="hqwebapp/base.html"
LOGIN_TEMPLATE="login_and_password/login.html"
LOGGEDOUT_TEMPLATE="loggedout.html"
# email settings: these ones are the custom hq ones
EMAIL_LOGIN="[email protected]"
EMAIL_PASSWORD="changeme"
EMAIL_SMTP_HOST="smtp.gmail.com"
EMAIL_SMTP_PORT=587
PAGINATOR_OBJECTS_PER_PAGE = 15
PAGINATOR_MAX_PAGE_LINKS = 5
# OpenRosa Standards
OPENROSA_VERSION = "1.0"
# OTA restore fixture generators
FIXTURE_GENERATORS = [
"corehq.apps.users.fixturegenerators.user_groups",
"corehq.apps.fixtures.fixturegenerators.item_lists",
]
# xep_hq_server settings
XEP_AUTHORIZE = 'corehq.apps.app_manager.models.authorize_xform_edit'
XEP_GET_XFORM = 'corehq.apps.app_manager.models.get_xform'
XEP_PUT_XFORM = 'corehq.apps.app_manager.models.put_xform'
GET_URL_BASE = 'dimagi.utils.web.get_url_base'
SMS_GATEWAY_URL = "http://localhost:8001/"
SMS_GATEWAY_PARAMS = "user=my_username&password=my_password&id=%(phone_number)s&text=%(message)s"
# celery
CARROT_BACKEND = "django"
SKIP_SOUTH_TESTS = True
#AUTH_PROFILE_MODULE = 'users.HqUserProfile'
TEST_RUNNER = 'testrunner.HqTestSuiteRunner'
HQ_ACCOUNT_ROOT = "commcarehq.org" # this is what gets appended to @domain after your accounts
XFORMS_PLAYER_URL = "http://localhost:4444/" # touchform's setting
# couchlog
SUPPORT_EMAIL = "[email protected]"
COUCHLOG_BLUEPRINT_HOME = "%s%s" % (STATIC_URL, "hqwebapp/stylesheets/blueprint/")
COUCHLOG_DATATABLES_LOC = "%s%s" % (STATIC_URL, "hqwebapp/datatables-1.8.2/js/jquery.dataTables.min.js")
# couchlog/case search
LUCENE_ENABLED = False
# sofabed
FORMDATA_MODEL = 'hqsofabed.HQFormData'
# unicel sms config
UNICEL_CONFIG = {"username": "Dimagi",
"password": "changeme",
"sender": "Promo" }
#auditcare parameters
AUDIT_VIEWS = [
'corehq.apps.domain.views.registration_request',
'corehq.apps.domain.views.registration_confirm',
'corehq.apps.domain.views.password_change',
'corehq.apps.domain.views.password_change_done',
'corehq.apps.reports.views.submit_history',
'corehq.apps.reports.views.active_cases',
'corehq.apps.reports.views.submit_history',
'corehq.apps.reports.views.default',
'corehq.apps.reports.views.submission_log',
'corehq.apps.reports.views.form_data',
'corehq.apps.reports.views.export_data',
'corehq.apps.reports.views.excel_report_data',
'corehq.apps.reports.views.daily_submissions',
]
# Don't use google analytics unless overridden in localsettings
GOOGLE_ANALYTICS_ID = ''
# import local settings if we find them
LOCAL_APPS = ()
LOCAL_MIDDLEWARE_CLASSES = ()
try:
#try to see if there's an environmental variable set for local_settings
if os.environ.has_key('CUSTOMSETTINGS') and os.environ['CUSTOMSETTINGS'] == "demo":
# this sucks, but is a workaround for supporting different settings
# in the same environment
from settings_demo import *
else:
from localsettings import *
except ImportError:
pass
####### South Settings #######
#SKIP_SOUTH_TESTS=True
#SOUTH_TESTS_MIGRATE=False
####### Couch Forms & Couch DB Kit Settings #######
from settingshelper import get_dynamic_db_settings
_dynamic_db_settings = get_dynamic_db_settings(COUCH_SERVER_ROOT, COUCH_USERNAME, COUCH_PASSWORD, COUCH_DATABASE_NAME, INSTALLED_APPS)
# create local server and database configs
COUCH_SERVER = _dynamic_db_settings["COUCH_SERVER"]
COUCH_DATABASE = _dynamic_db_settings["COUCH_DATABASE"]
# other urls that depend on the server
XFORMS_POST_URL = _dynamic_db_settings["XFORMS_POST_URL"]
COUCHDB_DATABASES = [(app_label, COUCH_DATABASE) for app_label in [
'api',
'app_manager',
'auditcare',
'builds',
'case',
'cleanup',
'cloudcare',
'couch', # This is necessary for abstract classes in dimagi.utils.couch.undo; otherwise breaks tests
'couchforms',
'couchexport',
'couchlog',
'hqadmin',
'domain',
'forms',
'fixtures',
'groups',
'hqcase',
'hqmedia',
'migration',
'phone',
'receiverwrapper',
'reminders',
'prescriptions',
'reports',
'sms',
'translations',
'users',
'formplayer',
'xep_hq_server',
'phonelog',
'pathfinder',
'registration',
'hutch',
'dca'
]
]
INSTALLED_APPS += LOCAL_APPS
MIDDLEWARE_CLASSES += LOCAL_MIDDLEWARE_CLASSES
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
},
'simple': {
'format': '%(levelname)s %(message)s'
},
},
'handlers': {
'console':{
'level':'INFO',
'class':'logging.StreamHandler',
'formatter': 'simple'
},
'file' : {
'level': 'INFO',
'class': 'logging.FileHandler',
'formatter': 'verbose',
'filename': DJANGO_LOG_FILE
},
'couchlog':{
'level':'WARNING',
'class':'couchlog.handlers.CouchHandler',
},
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler',
}
},
'loggers': {
'': {
'handlers':['console', 'file', 'couchlog'],
'propagate': True,
'level':'INFO',
},
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
}
}
}
# these are the official django settings
# which really we should be using over the
# above
EMAIL_HOST = EMAIL_SMTP_HOST
EMAIL_PORT = EMAIL_SMTP_PORT
EMAIL_HOST_USER = EMAIL_LOGIN
EMAIL_HOST_PASSWORD = EMAIL_PASSWORD
EMAIL_USE_TLS = True
STANDARD_REPORT_MAP = {
"Monitor Workers" : ['corehq.apps.reports.standard.CaseActivityReport',
'corehq.apps.reports.standard.SubmissionsByFormReport',
'corehq.apps.reports.standard.DailySubmissionsReport',
'corehq.apps.reports.standard.DailyFormCompletionsReport',
'corehq.apps.reports.standard.FormCompletionTrendsReport',
'corehq.apps.reports.standard.SubmissionTimesReport',
'corehq.apps.reports.standard.SubmitDistributionReport',
],
"Inspect Data" : ['corehq.apps.reports.standard.SubmitHistory',
'corehq.apps.reports.standard.CaseListReport',
],
"Raw Data" : ['corehq.apps.reports.standard.ExcelExportReport',
'corehq.apps.reports.standard.CaseExportReport',
],
"Manage Deployments" : ['corehq.apps.reports.standard.ApplicationStatusReport',
]
}
CUSTOM_REPORT_MAP = {
"pathfinder": [
'pathfinder.models.PathfinderHBCReport',
'pathfinder.models.PathfinderProviderReport',
'pathfinder.models.PathfinderWardSummaryReport'
],
"dca-malawi": [
'dca.reports.ProjectOfficerReport',
'dca.reports.PortfolioComparisonReport',
'dca.reports.PerformanceReport',
'dca.reports.PerformanceRatiosReport']
}
MESSAGE_TAGS = {
messages.INFO: 'alert-info',
messages.DEBUG: '',
messages.SUCCESS: 'alert-success',
messages.WARNING: 'alert-error',
messages.ERROR: 'alert-error',
}
COMMCARE_USER_TERM = "Mobile Worker"
WEB_USER_TERM = "Web User"