adding a management command to santize schools from the usde database
[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
96 # See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS
97 STATICFILES_DIRS = (
98     normpath(join(DJANGO_ROOT, 'assets')),
99 )
100
101 # See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-finders
102 STATICFILES_FINDERS = (
103     'django.contrib.staticfiles.finders.FileSystemFinder',
104     'django.contrib.staticfiles.finders.AppDirectoriesFinder',
105     'compressor.finders.CompressorFinder',
106 )
107 ########## END STATIC FILE CONFIGURATION
108
109
110 ########## SECRET CONFIGURATION
111 # See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
112 SECRET_KEY = r"(s1k!&^7l28k&nrm2ek(qqo&19%y(zn#=^zq_*ur2@irjun0x4"
113 ########## END SECRET CONFIGURATION
114
115
116 ########## FIXTURE CONFIGURATION
117 # See: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FIXTURE_DIRS
118 FIXTURE_DIRS = (
119     normpath(join(DJANGO_ROOT, 'fixtures')),
120 )
121 ########## END FIXTURE CONFIGURATION
122
123
124 ########## TEMPLATE CONFIGURATION
125 # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors
126 TEMPLATE_CONTEXT_PROCESSORS = (
127     'django.contrib.auth.context_processors.auth',
128     'django.core.context_processors.debug',
129     'django.core.context_processors.i18n',
130     'django.core.context_processors.media',
131     'django.core.context_processors.static',
132     'django.core.context_processors.tz',
133     'django.contrib.messages.context_processors.messages',
134     'django.core.context_processors.request',
135 )
136
137 # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-loaders
138 TEMPLATE_LOADERS = (
139     'django.template.loaders.filesystem.Loader',
140     'django.template.loaders.app_directories.Loader',
141 )
142
143 # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs
144 TEMPLATE_DIRS = (
145     normpath(join(DJANGO_ROOT, 'templates')),
146 )
147 ########## END TEMPLATE CONFIGURATION
148
149
150 ########## MIDDLEWARE CONFIGURATION
151 # See: https://docs.djangoproject.com/en/dev/ref/settings/#middleware-classes
152 MIDDLEWARE_CLASSES = (
153     # Use GZip compression to reduce bandwidth.
154     'django.middleware.gzip.GZipMiddleware',
155
156     # Default Django middleware.
157     'django.middleware.common.CommonMiddleware',
158     'django.contrib.sessions.middleware.SessionMiddleware',
159     'django.middleware.csrf.CsrfViewMiddleware',
160     'django.contrib.auth.middleware.AuthenticationMiddleware',
161     'django.contrib.messages.middleware.MessageMiddleware',
162 )
163 ########## END MIDDLEWARE CONFIGURATION
164
165
166 ########## URL CONFIGURATION
167 # See: https://docs.djangoproject.com/en/dev/ref/settings/#root-urlconf
168 ROOT_URLCONF = '%s.urls' % SITE_NAME
169 ########## END URL CONFIGURATION
170
171
172 ########## APP CONFIGURATION
173 DJANGO_APPS = (
174     # Default Django apps:
175     'django.contrib.auth',
176     'django.contrib.contenttypes',
177     'django.contrib.sessions',
178     'django.contrib.sites',
179     'django.contrib.messages',
180     'django.contrib.staticfiles',
181
182     # Useful template tags:
183     'django.contrib.humanize',
184
185     # grappelli django-admin improvment, must be added before admin
186     'grappelli',
187
188     # Admin panel and documentation:
189     'django.contrib.admin',
190     'django.contrib.admindocs',
191 )
192
193 THIRD_PARTY_APPS = (
194     # Database migration helpers:
195     'south',
196
197     # Static file management:
198     'compressor',
199
200     # Asynchronous task queue:
201     'djcelery',
202
203     # Tagging https://github.com/yedpodtrzitko/django-taggit
204     'taggit',
205 )
206
207 LOCAL_APPS = (
208     # file handling app
209     'karmaworld.apps.notes',
210     'karmaworld.apps.courses',
211     'karmaworld.apps.ajaxuploader',
212 )
213
214 # See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
215 INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
216 ########## END APP CONFIGURATION
217
218
219 ########## LOGGING CONFIGURATION
220 # See: https://docs.djangoproject.com/en/dev/ref/settings/#logging
221 LOGGING = {
222     'version': 1,
223     'disable_existing_loggers': False,
224     'handlers': {
225         'mail_admins': {
226             'level': 'ERROR',
227             'class': 'django.utils.log.AdminEmailHandler'
228         }
229     },
230     'loggers': {
231         'django.request': {
232             'handlers': ['mail_admins'],
233             'level': 'ERROR',
234             'propagate': True,
235         },
236     }
237 }
238 ########## END LOGGING CONFIGURATION
239
240
241 ########## CELERY CONFIGURATION
242 # See: http://celery.readthedocs.org/en/latest/configuration.html#celery-task-result-expires
243 CELERY_TASK_RESULT_EXPIRES = timedelta(minutes=30)
244
245 # See: http://celery.github.com/celery/django/
246 setup_loader()
247 ########## END CELERY CONFIGURATION
248
249
250 ########## WSGI CONFIGURATION
251 # See: https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application
252 WSGI_APPLICATION = 'wsgi.application'
253 ########## END WSGI CONFIGURATION
254
255
256 ########## COMPRESSION CONFIGURATION
257 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_ENABLED
258 COMPRESS_ENABLED = True
259
260 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_CSS_FILTERS
261 COMPRESS_CSS_FILTERS = [
262     'compressor.filters.template.TemplateFilter',
263 ]
264
265 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_JS_FILTERS
266 COMPRESS_JS_FILTERS = [
267     'compressor.filters.template.TemplateFilter',
268 ]
269 ########## END COMPRESSION CONFIGURATION
270
271 ########## TAGGIT CONFIGURATION
272 # From https://github.com/yedpodtrzitko/django-taggit
273
274 # Use lowercase tags
275 TAGGIT_FORCE_LOWERCASE = True
276
277 # Ignore common stopwords
278 TAGGIT_STOPWORDS = [u'a', u'an', u'and', u'be', u'from', u'of']
279
280 ########## END TAGGIT CONFIGURATION
281