]> git.openstreetmap.org Git - osqa.git/blob - settings.py
fixes OSQA 555 and OSQA 294
[osqa.git] / settings.py
1 # encoding:utf-8
2 # Django settings for lanai project.
3 import os.path
4 import sys
5
6 SITE_ID = 1
7
8 ADMIN_MEDIA_PREFIX = '/admin_media/'
9 SECRET_KEY = '$oo^&_m&qwbib=(_4m_n*zn-d=g#s0he5fx9xonnym#8p6yigm'
10 # List of callables that know how to import templates from various sources.
11 TEMPLATE_LOADERS = (
12     'django.template.loaders.filesystem.load_template_source',
13     'django.template.loaders.app_directories.load_template_source',
14     'forum.modules.module_templates_loader',
15     'forum.skins.load_template_source',
16 #     'django.template.loaders.eggs.load_template_source',
17 )
18
19 MIDDLEWARE_CLASSES = [
20     #'django.middleware.gzip.GZipMiddleware',
21     'django.contrib.sessions.middleware.SessionMiddleware',
22     #'django.middleware.locale.LocaleMiddleware',
23     #'django.middleware.cache.UpdateCacheMiddleware',
24     'django.middleware.common.CommonMiddleware',
25     #'django.middleware.cache.FetchFromCacheMiddleware',
26     'forum.middleware.extended_user.ExtendedUser',
27     #'django.middleware.sqlprint.SqlPrintingMiddleware',
28     'forum.middleware.anon_user.ConnectToSessionMessagesMiddleware',
29     'forum.middleware.request_utils.RequestUtils',
30     'forum.middleware.cancel.CancelActionMiddleware',
31     #'recaptcha_django.middleware.ReCaptchaMiddleware',
32     'django.middleware.transaction.TransactionMiddleware',
33 ]
34
35 TEMPLATE_CONTEXT_PROCESSORS = (
36     'django.core.context_processors.request',
37     'forum.context.application_settings',
38     #'django.core.context_processors.i18n',
39     'forum.user_messages.context_processors.user_messages',#must be before auth
40     'django.core.context_processors.auth', #this is required for admin
41 )
42
43 ROOT_URLCONF = 'urls'
44
45 TEMPLATE_DIRS = (
46     os.path.join(os.path.dirname(__file__),'forum','skins').replace('\\','/'),
47 )
48
49 #UPLOAD SETTINGS
50 FILE_UPLOAD_TEMP_DIR = os.path.join(os.path.dirname(__file__), 'tmp').replace('\\','/')
51 FILE_UPLOAD_HANDLERS = ("django.core.files.uploadhandler.MemoryFileUploadHandler",
52  "django.core.files.uploadhandler.TemporaryFileUploadHandler",)
53 DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'
54 # for user upload
55 ALLOW_FILE_TYPES = ('.jpg', '.jpeg', '.gif', '.bmp', '.png', '.tiff')
56 # unit byte
57 ALLOW_MAX_FILE_SIZE = 1024 * 1024
58
59 # User settings
60 from settings_local import *
61
62 try:
63     if len(FORUM_SCRIPT_ALIAS) > 0:
64         APP_URL = '%s/%s' % (APP_URL, FORUM_SCRIPT_ALIAS[:-1])
65 except NameError:
66     pass
67
68 app_url_split = APP_URL.split("://")
69
70 APP_PROTOCOL = app_url_split[0]
71 APP_DOMAIN = app_url_split[1].split('/')[0]
72 APP_BASE_URL = '%s://%s' % (APP_PROTOCOL, APP_DOMAIN)
73
74 FORCE_SCRIPT_NAME = ''
75
76 for path in app_url_split[1].split('/')[1:]:
77     FORCE_SCRIPT_NAME = FORCE_SCRIPT_NAME + '/' + path
78
79 if FORCE_SCRIPT_NAME.endswith('/'):
80     FORCE_SCRIPT_NAME = FORCE_SCRIPT_NAME[:-1]
81
82 INSTALLED_APPS = [
83     'django.contrib.auth',
84     'django.contrib.contenttypes',
85     'django.contrib.sessions',
86     'django.contrib.sites',
87     'django.contrib.admin',
88     'django.contrib.humanize',
89     'django.contrib.sitemaps',
90     'django.contrib.markup',
91     'forum',
92 ]
93
94 if DEBUG:
95     try:
96         import debug_toolbar
97         MIDDLEWARE_CLASSES.append('debug_toolbar.middleware.DebugToolbarMiddleware')
98         INSTALLED_APPS.append('debug_toolbar')
99     except:
100         pass
101
102 try:
103     import south
104     INSTALLED_APPS.append('south')
105 except:
106     pass
107
108 if not DEBUG:
109     try:
110         import rosetta
111         INSTALLED_APPS.append('rosetta')
112     except:
113         pass
114
115 AUTHENTICATION_BACKENDS = ['django.contrib.auth.backends.ModelBackend',]