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