bfc6fb199f563c1975aa8ae10e3eb0d74a0c7cc4
[oweals/karmaworld.git] / karmaworld / settings / common.py
1 #!/usr/bin/env python
2 # -*- coding:utf8 -*-
3 # Copyright (C) 2012  FinalsClub Foundation
4 """ Common settings and globals. """
5
6
7 from datetime import timedelta
8 from os.path import abspath, basename, dirname, join, normpath
9 from sys import path
10
11 from djcelery import setup_loader
12
13 from karmaworld.secret.filepicker import FILEPICKER_API_KEY as fp_api
14
15 FILEPICKER_API_KEY = fp_api
16
17
18 ########## PATH CONFIGURATION
19 # Absolute filesystem path to the Django project directory:
20 DJANGO_ROOT = dirname(dirname(abspath(__file__)))
21
22 # Absolute filesystem path to the top-level project folder:
23 SITE_ROOT = dirname(DJANGO_ROOT)
24
25 # Site name:
26 SITE_NAME = basename(DJANGO_ROOT)
27
28 # Add our project to our pythonpath, this way we don't need to type our project
29 # name in our dotted import paths:
30 path.append(DJANGO_ROOT)
31 ########## END PATH CONFIGURATION
32
33
34 ########## DEBUG CONFIGURATION
35 # See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
36 DEBUG = False
37
38 # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
39 TEMPLATE_DEBUG = DEBUG
40 ########## END DEBUG CONFIGURATION
41
42
43 ########## MANAGER CONFIGURATION
44 # See: https://docs.djangoproject.com/en/dev/ref/settings/#admins
45 ADMINS = (
46     ('Seth Woodworth', 'seth@finalsclub.org'),
47     ('Charles Holbrow', 'charles@finalsclub.org'),
48     ('Andrew Magliozzi', 'andrew@finalsclub.org'),
49 )
50
51 # See: https://docs.djangoproject.com/en/dev/ref/settings/#managers
52 MANAGERS = ADMINS
53 ########## END MANAGER CONFIGURATION
54
55
56 ########## DATABASE CONFIGURATION
57 # See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
58 DATABASES = {
59     'default': {
60         'ENGINE': 'django.db.backends.',
61         'NAME': '',
62         'USER': '',
63         'PASSWORD': '',
64         'HOST': '',
65         'PORT': '',
66     }
67 }
68 ########## END DATABASE CONFIGURATION
69
70
71 ########## GENERAL CONFIGURATION
72 # See: https://docs.djangoproject.com/en/dev/ref/settings/#time-zone
73 TIME_ZONE = 'America/New_York'
74
75 # See: https://docs.djangoproject.com/en/dev/ref/settings/#language-code
76 LANGUAGE_CODE = 'en-us'
77
78 # See: https://docs.djangoproject.com/en/dev/ref/settings/#site-id
79 SITE_ID = 1
80
81 # See: https://docs.djangoproject.com/en/dev/ref/settings/#use-i18n
82 USE_I18N = True
83
84 # See: https://docs.djangoproject.com/en/dev/ref/settings/#use-l10n
85 USE_L10N = True
86 ########## END GENERAL CONFIGURATION
87
88
89 ########## MEDIA CONFIGURATION
90 # See: https://docs.djangoproject.com/en/dev/ref/settings/#media-root
91 MEDIA_ROOT = normpath(join(DJANGO_ROOT, 'media'))
92
93 # See: https://docs.djangoproject.com/en/dev/ref/settings/#media-url
94 MEDIA_URL = '/media/'
95 ########## END MEDIA CONFIGURATION
96
97
98 ########## STATIC FILE CONFIGURATION
99
100 # See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS
101 STATICFILES_DIRS = (
102     normpath(join(DJANGO_ROOT, 'assets')),
103 )
104
105 # See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-finders
106 STATICFILES_FINDERS = (
107     'django.contrib.staticfiles.finders.FileSystemFinder',
108     'django.contrib.staticfiles.finders.AppDirectoriesFinder',
109     'compressor.finders.CompressorFinder',
110 )
111 ########## END STATIC FILE CONFIGURATION
112
113
114 ########## SECRET CONFIGURATION
115 # See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
116 SECRET_KEY = r"(s1k!&^7l28k&nrm2ek(qqo&19%y(zn#=^zq_*ur2@irjun0x4"
117 ########## END SECRET CONFIGURATION
118
119
120 ########## FIXTURE CONFIGURATION
121 # See: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FIXTURE_DIRS
122 FIXTURE_DIRS = (
123     normpath(join(DJANGO_ROOT, 'fixtures')),
124 )
125 ########## END FIXTURE CONFIGURATION
126
127
128 ########## TEMPLATE CONFIGURATION
129 # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors
130 TEMPLATE_CONTEXT_PROCESSORS = (
131     'django.contrib.auth.context_processors.auth',
132     'django.core.context_processors.debug',
133     'django.core.context_processors.i18n',
134     'django.core.context_processors.media',
135     'django.core.context_processors.static',
136     'django.core.context_processors.tz',
137     'django.contrib.messages.context_processors.messages',
138     'django.core.context_processors.request',
139 )
140
141 # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-loaders
142 TEMPLATE_LOADERS = (
143     'django.template.loaders.filesystem.Loader',
144     'django.template.loaders.app_directories.Loader',
145 )
146
147 # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs
148 TEMPLATE_DIRS = (
149     normpath(join(DJANGO_ROOT, 'templates')),
150 )
151 ########## END TEMPLATE CONFIGURATION
152
153
154 ########## MIDDLEWARE CONFIGURATION
155 # See: https://docs.djangoproject.com/en/dev/ref/settings/#middleware-classes
156 MIDDLEWARE_CLASSES = (
157     # Use GZip compression to reduce bandwidth.
158     'django.middleware.gzip.GZipMiddleware',
159
160     # Default Django middleware.
161     'django.middleware.common.CommonMiddleware',
162     'django.contrib.sessions.middleware.SessionMiddleware',
163     'django.middleware.csrf.CsrfViewMiddleware',
164     'django.contrib.auth.middleware.AuthenticationMiddleware',
165     'django.contrib.messages.middleware.MessageMiddleware',
166 )
167 ########## END MIDDLEWARE CONFIGURATION
168
169
170 ########## URL CONFIGURATION
171 # See: https://docs.djangoproject.com/en/dev/ref/settings/#root-urlconf
172 ROOT_URLCONF = '%s.urls' % SITE_NAME
173 ########## END URL CONFIGURATION
174
175
176 ########## APP CONFIGURATION
177 DJANGO_APPS = (
178     # Default Django apps:
179     'django.contrib.auth',
180     'django.contrib.contenttypes',
181     'django.contrib.sessions',
182     'django.contrib.sites',
183     'django.contrib.messages',
184     'django.contrib.staticfiles',
185
186     # Useful template tags:
187     'django.contrib.humanize',
188
189     # grappelli django-admin improvment, must be added before admin
190     'grappelli',
191
192     # Admin panel and documentation:
193     'django.contrib.admin',
194     'django.contrib.admindocs',
195 )
196
197 THIRD_PARTY_APPS = (
198     # Database migration helpers:
199     'south',
200
201     # Static file management:
202     'compressor',
203
204     # Asynchronous task queue:
205     'djcelery',
206
207     # Tagging https://github.com/yedpodtrzitko/django-taggit
208     'taggit',
209 )
210
211 LOCAL_APPS = (
212     # file handling app
213     'karmaworld.apps.notes',
214     'karmaworld.apps.courses',
215     'karmaworld.apps.document_upload',
216     'karmaworld.apps.users',
217     'karmaworld.apps.moderation',
218     'karmaworld.apps.licenses',
219 )
220
221 # See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
222 INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
223 ########## END APP CONFIGURATION
224
225
226 ########## LOGGING CONFIGURATION
227 # See: https://docs.djangoproject.com/en/dev/ref/settings/#logging
228 LOGGING = {
229     'version': 1,
230     'disable_existing_loggers': False,
231     'handlers': {
232         'console': {
233             'level': 'INFO',
234             'class': 'logging.StreamHandler'
235         },
236         'mail_admins': {
237             'level': 'ERROR',
238             'class': 'django.utils.log.AdminEmailHandler'
239         }
240     },
241     'loggers': {
242         'django': {
243             'handlers': ['console'],
244             'level': 'INFO'
245         },
246         'django.request': {
247             'handlers': ['mail_admins'],
248             'level': 'ERROR',
249             'propagate': True
250         },
251     }
252 }
253 ########## END LOGGING CONFIGURATION
254
255
256 ########## CELERY CONFIGURATION
257 # See: http://celery.readthedocs.org/en/latest/configuration.html#celery-task-result-expires
258 CELERY_TASK_RESULT_EXPIRES = timedelta(minutes=30)
259
260 # See: http://celery.github.com/celery/django/
261 setup_loader()
262 ########## END CELERY CONFIGURATION
263
264
265 ########## WSGI CONFIGURATION
266 # See: https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application
267 WSGI_APPLICATION = 'wsgi.application'
268 ########## END WSGI CONFIGURATION
269
270
271 ########## COMPRESSION CONFIGURATION
272 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_ENABLED
273 COMPRESS_ENABLED = True
274
275 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_CSS_FILTERS
276 COMPRESS_CSS_FILTERS = [
277     'compressor.filters.template.TemplateFilter',
278 ]
279
280 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_JS_FILTERS
281 COMPRESS_JS_FILTERS = [
282     'compressor.filters.template.TemplateFilter',
283 ]
284 ########## END COMPRESSION CONFIGURATION
285
286 ########## SESSION CONFIGURATION
287
288 SESSION_COOKIE_AGE = 63072000    # 2 years in seconds
289
290 ########## END SESSION CONFIGURATION
291
292 ########## TAGGIT CONFIGURATION
293 # From https://github.com/yedpodtrzitko/django-taggit
294
295 # Use lowercase tags
296 TAGGIT_FORCE_LOWERCASE = True
297
298 # Ignore common stopwords
299 TAGGIT_STOPWORDS = [u'a', u'an', u'and', u'be', u'from', u'of']
300
301 ########## END TAGGIT CONFIGURATION
302