]> git.openstreetmap.org Git - osqa.git/blob - settings.py
simple css fix on answer-body
[osqa.git] / settings.py
1 # encoding:utf-8
2 import os.path
3 import sys
4
5 SITE_ID = 1
6
7 ADMIN_MEDIA_PREFIX = '/admin_media/'
8 SECRET_KEY = '$oo^&_m&qwbib=(_4m_n*zn-d=g#s0he5fx9xonnym#8p6yigm'
9
10 TEMPLATE_LOADERS = [
11     'django.template.loaders.filesystem.load_template_source',
12     'django.template.loaders.app_directories.load_template_source',
13     'forum.modules.template_loader.module_templates_loader',
14     'forum.skins.load_template_source',
15 ]
16
17 MIDDLEWARE_CLASSES = [
18     'forum.middleware.django_cookies.CookiePreHandlerMiddleware',
19     'django.contrib.sessions.middleware.SessionMiddleware',
20     'django.middleware.common.CommonMiddleware',
21     'forum.middleware.extended_user.ExtendedUser',
22     'forum.middleware.anon_user.ConnectToSessionMessagesMiddleware',
23     'forum.middleware.request_utils.RequestUtils',
24     'forum.middleware.cancel.CancelActionMiddleware',
25     'forum.middleware.admin_messages.AdminMessagesMiddleware',
26     'django.middleware.transaction.TransactionMiddleware',
27     'forum.middleware.django_cookies.CookiePostHandlerMiddleware',
28 ]
29 # Backwards compatibility. If we fail to import the CSRF middle-ware from the location
30 # where it is supposed to be, we add the old middle-ware classes to the classes list.
31 try:
32     from django.middleware.csrf import CsrfViewMiddleware
33     MIDDLEWARE_CLASSES = [
34         'django.middleware.csrf.CsrfViewMiddleware',
35         'django.middleware.csrf.CsrfResponseMiddleware',
36     ] + MIDDLEWARE_CLASSES
37 except ImportError:
38     MIDDLEWARE_CLASSES = [
39         'django.contrib.csrf.middleware.CsrfViewMiddleware',
40         'django.contrib.csrf.middleware.CsrfResponseMiddleware',
41     ] + MIDDLEWARE_CLASSES
42
43 TEMPLATE_CONTEXT_PROCESSORS = [
44     'django.core.context_processors.request',
45     'forum.context.application_settings',
46     'forum.user_messages.context_processors.user_messages',
47     'django.core.context_processors.auth',
48 ]
49
50 ROOT_URLCONF = 'urls'
51 APPEND_SLASH = True
52
53 TEMPLATE_DIRS = (
54     os.path.join(os.path.dirname(__file__),'forum','skins').replace('\\','/'),
55 )
56
57
58 FILE_UPLOAD_TEMP_DIR = os.path.join(os.path.dirname(__file__), 'tmp').replace('\\','/')
59 FILE_UPLOAD_HANDLERS = ("django.core.files.uploadhandler.MemoryFileUploadHandler",
60  "django.core.files.uploadhandler.TemporaryFileUploadHandler",)
61 DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'
62
63 ALLOW_FILE_TYPES = ('.jpg', '.jpeg', '.gif', '.bmp', '.png', '.tiff')
64 ALLOW_MAX_FILE_SIZE = 1024 * 1024
65
66 # User settings
67 from settings_local import *
68
69 try:
70     if len(FORUM_SCRIPT_ALIAS) > 0:
71         APP_URL = '%s/%s' % (APP_URL, FORUM_SCRIPT_ALIAS[:-1])
72 except NameError:
73     pass
74
75 app_url_split = APP_URL.split("://")
76
77 APP_PROTOCOL = app_url_split[0]
78 APP_DOMAIN = app_url_split[1].split('/')[0]
79 APP_BASE_URL = '%s://%s' % (APP_PROTOCOL, APP_DOMAIN)
80
81 FORCE_SCRIPT_NAME = ''
82
83 for path in app_url_split[1].split('/')[1:]:
84     FORCE_SCRIPT_NAME = FORCE_SCRIPT_NAME + '/' + path
85
86 if FORCE_SCRIPT_NAME.endswith('/'):
87     FORCE_SCRIPT_NAME = FORCE_SCRIPT_NAME[:-1]
88
89 #Module system initialization
90 MODULES_PACKAGE = 'forum_modules'
91 MODULES_FOLDER = os.path.join(SITE_SRC_ROOT, MODULES_PACKAGE)
92
93 MODULE_LIST = filter(lambda m: getattr(m, 'CAN_USE', True), [
94         __import__('forum_modules.%s' % f, globals(), locals(), ['forum_modules'])
95         for f in os.listdir(MODULES_FOLDER)
96         if os.path.isdir(os.path.join(MODULES_FOLDER, f)) and
97            os.path.exists(os.path.join(MODULES_FOLDER, "%s/__init__.py" % f)) and
98            not f in DISABLED_MODULES
99 ])
100
101 [MIDDLEWARE_CLASSES.extend(
102         ["%s.%s" % (m.__name__, mc) for mc in getattr(m, 'MIDDLEWARE_CLASSES', [])]
103                           ) for m in MODULE_LIST]
104
105 [TEMPLATE_LOADERS.extend(
106         ["%s.%s" % (m.__name__, tl) for tl in getattr(m, 'TEMPLATE_LOADERS', [])]
107                           ) for m in MODULE_LIST]
108
109
110 INSTALLED_APPS = [
111     'django.contrib.auth',
112     'django.contrib.contenttypes',
113     'django.contrib.sessions',
114     'django.contrib.sites',
115     'django.contrib.admin',
116     'django.contrib.humanize',
117     'django.contrib.sitemaps',
118     'django.contrib.markup',
119     'forum',
120 ]
121
122 if DEBUG:
123     try:
124         import debug_toolbar
125         MIDDLEWARE_CLASSES.append('debug_toolbar.middleware.DebugToolbarMiddleware')
126         INSTALLED_APPS.append('debug_toolbar')
127     except:
128         pass
129
130 try:
131     import south
132     INSTALLED_APPS.append('south')
133 except:
134     pass
135
136 if not DEBUG:
137     try:
138         import rosetta
139         INSTALLED_APPS.append('rosetta')
140     except:
141         pass
142
143 AUTHENTICATION_BACKENDS = ['django.contrib.auth.backends.ModelBackend',]