cleaning up shebang, copyright and file encoding for virtualenv
[oweals/karmaworld.git] / karmaworld / settings / common.py
1 """Common settings and globals."""
2
3
4 from datetime import timedelta
5 from os.path import abspath, basename, dirname, join, normpath
6 from sys import path
7
8 from djcelery import setup_loader
9
10
11 ########## PATH CONFIGURATION
12 # Absolute filesystem path to the Django project directory:
13 DJANGO_ROOT = dirname(dirname(abspath(__file__)))
14
15 # Absolute filesystem path to the top-level project folder:
16 SITE_ROOT = dirname(DJANGO_ROOT)
17
18 # Site name:
19 SITE_NAME = basename(DJANGO_ROOT)
20
21 # Add our project to our pythonpath, this way we don't need to type our project
22 # name in our dotted import paths:
23 path.append(DJANGO_ROOT)
24 ########## END PATH CONFIGURATION
25
26
27 ########## DEBUG CONFIGURATION
28 # See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
29 DEBUG = False
30
31 # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
32 TEMPLATE_DEBUG = DEBUG
33 ########## END DEBUG CONFIGURATION
34
35
36 ########## MANAGER CONFIGURATION
37 # See: https://docs.djangoproject.com/en/dev/ref/settings/#admins
38 ADMINS = (
39     ('Your Name', 'your_email@example.com'),
40 )
41
42 # See: https://docs.djangoproject.com/en/dev/ref/settings/#managers
43 MANAGERS = ADMINS
44 ########## END MANAGER CONFIGURATION
45
46
47 ########## DATABASE CONFIGURATION
48 # See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
49 DATABASES = {
50     'default': {
51         'ENGINE': 'django.db.backends.',
52         'NAME': '',
53         'USER': '',
54         'PASSWORD': '',
55         'HOST': '',
56         'PORT': '',
57     }
58 }
59 ########## END DATABASE CONFIGURATION
60
61
62 ########## GENERAL CONFIGURATION
63 # See: https://docs.djangoproject.com/en/dev/ref/settings/#time-zone
64 TIME_ZONE = 'America/Los_Angeles'
65
66 # See: https://docs.djangoproject.com/en/dev/ref/settings/#language-code
67 LANGUAGE_CODE = 'en-us'
68
69 # See: https://docs.djangoproject.com/en/dev/ref/settings/#site-id
70 SITE_ID = 1
71
72 # See: https://docs.djangoproject.com/en/dev/ref/settings/#use-i18n
73 USE_I18N = True
74
75 # See: https://docs.djangoproject.com/en/dev/ref/settings/#use-l10n
76 USE_L10N = True
77 ########## END GENERAL CONFIGURATION
78
79
80 ########## MEDIA CONFIGURATION
81 # See: https://docs.djangoproject.com/en/dev/ref/settings/#media-root
82 MEDIA_ROOT = normpath(join(DJANGO_ROOT, 'media'))
83
84 # See: https://docs.djangoproject.com/en/dev/ref/settings/#media-url
85 MEDIA_URL = '/media/'
86 ########## END MEDIA CONFIGURATION
87
88
89 ########## STATIC FILE CONFIGURATION
90 # See: https://docs.djangoproject.com/en/dev/ref/settings/#static-root
91 STATIC_ROOT = normpath(join(DJANGO_ROOT, 'static'))
92
93 # See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
94 STATIC_URL = '/static/'
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     # Admin panel and documentation:
186     'django.contrib.admin',
187     'django.contrib.admindocs',
188 )
189
190 THIRD_PARTY_APPS = (
191     # Database migration helpers:
192     'south',
193
194     # Static file management:
195     'compressor',
196
197     # Asynchronous task queue:
198     'djcelery',
199
200     # Tagging https://github.com/yedpodtrzitko/django-taggit
201     'taggit',
202 )
203
204 LOCAL_APPS = (
205     # file handling app
206     'karmaworld.apps.notes',
207     'karmaworld.apps.courses',
208 )
209
210 # See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
211 INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
212 ########## END APP CONFIGURATION
213
214
215 ########## LOGGING CONFIGURATION
216 # See: https://docs.djangoproject.com/en/dev/ref/settings/#logging
217 LOGGING = {
218     'version': 1,
219     'disable_existing_loggers': False,
220     'handlers': {
221         'mail_admins': {
222             'level': 'ERROR',
223             'class': 'django.utils.log.AdminEmailHandler'
224         }
225     },
226     'loggers': {
227         'django.request': {
228             'handlers': ['mail_admins'],
229             'level': 'ERROR',
230             'propagate': True,
231         },
232     }
233 }
234 ########## END LOGGING CONFIGURATION
235
236
237 ########## CELERY CONFIGURATION
238 # See: http://celery.readthedocs.org/en/latest/configuration.html#celery-task-result-expires
239 CELERY_TASK_RESULT_EXPIRES = timedelta(minutes=30)
240
241 # See: http://celery.github.com/celery/django/
242 setup_loader()
243 ########## END CELERY CONFIGURATION
244
245
246 ########## WSGI CONFIGURATION
247 # See: https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application
248 WSGI_APPLICATION = 'wsgi.application'
249 ########## END WSGI CONFIGURATION
250
251
252 ########## COMPRESSION CONFIGURATION
253 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_ENABLED
254 COMPRESS_ENABLED = True
255
256 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_CSS_FILTERS
257 COMPRESS_CSS_FILTERS = [
258     'compressor.filters.template.TemplateFilter',
259 ]
260
261 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_JS_FILTERS
262 COMPRESS_JS_FILTERS = [
263     'compressor.filters.template.TemplateFilter',
264 ]
265 ########## END COMPRESSION CONFIGURATION
266
267 ########## TAGGIT CONFIGURATION
268 # From https://github.com/yedpodtrzitko/django-taggit
269
270 # Use lowercase tags
271 TAGGIT_FORCE_LOWERCASE = True
272
273 # Ignore common stopwords
274 TAGGIT_STOPWORDS = [u'a', u'an', u'and', u'be', u'from', u'of']
275
276 ########## END TAGGIT CONFIGURATION
277