3 # Copyright (C) 2012 FinalsClub Foundation
4 """ Common settings and globals. """
7 from datetime import timedelta
8 from os.path import abspath, basename, dirname, join, normpath
11 from djcelery import setup_loader
13 from karmaworld.secret.filepicker import FILEPICKER_API_KEY as fp_api
15 FILEPICKER_API_KEY = fp_api
17 from karmaworld.secret.static_s3 import *
19 SERIALIZATION_MODULES = {'json-pretty': 'karmaworld.apps.serializers.json_pretty'}
22 ########## REQUIRED SECURITY CONFIGURATION
23 # See: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-ALLOWED_HOSTS
24 # The hosts that this server runs from.
26 '127.0.0.1', # for dev systems / VMs, but should be safe enough
27 'localhost', # for dev systems / VMs, but should be safe enough
28 'beta.karmanotes.org',
32 ########## END SECURITY CONFIGURATION
34 ########## PATH CONFIGURATION
35 # Absolute filesystem path to the Django project directory:
36 DJANGO_ROOT = dirname(dirname(abspath(__file__)))
38 # Absolute filesystem path to the top-level project folder:
39 SITE_ROOT = dirname(DJANGO_ROOT)
42 SITE_NAME = basename(DJANGO_ROOT)
44 # Add our project to our pythonpath, this way we don't need to type our project
45 # name in our dotted import paths:
46 path.append(DJANGO_ROOT)
47 ########## END PATH CONFIGURATION
50 ########## DEBUG CONFIGURATION
51 # See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
54 # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
55 TEMPLATE_DEBUG = DEBUG
56 ########## END DEBUG CONFIGURATION
59 ########## MANAGER CONFIGURATION
60 # See: https://docs.djangoproject.com/en/dev/ref/settings/#admins
62 ('Seth Woodworth', 'seth@finalsclub.org'),
63 ('Charles Holbrow', 'charles@finalsclub.org'),
64 ('Andrew Magliozzi', 'andrew@finalsclub.org'),
67 # See: https://docs.djangoproject.com/en/dev/ref/settings/#managers
69 ########## END MANAGER CONFIGURATION
72 ########## DATABASE CONFIGURATION
73 # See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
76 'ENGINE': 'django.db.backends.',
84 ########## END DATABASE CONFIGURATION
87 ########## GENERAL CONFIGURATION
88 # See: https://docs.djangoproject.com/en/dev/ref/settings/#time-zone
89 TIME_ZONE = 'America/New_York'
91 # See: https://docs.djangoproject.com/en/dev/ref/settings/#language-code
92 LANGUAGE_CODE = 'en-us'
94 # See: https://docs.djangoproject.com/en/dev/ref/settings/#site-id
97 # See: https://docs.djangoproject.com/en/dev/ref/settings/#use-i18n
100 # See: https://docs.djangoproject.com/en/dev/ref/settings/#use-l10n
102 ########## END GENERAL CONFIGURATION
105 ########## MEDIA CONFIGURATION
106 # See: https://docs.djangoproject.com/en/dev/ref/settings/#media-root
107 MEDIA_ROOT = normpath(join(DJANGO_ROOT, 'media'))
109 # See: https://docs.djangoproject.com/en/dev/ref/settings/#media-url
110 MEDIA_URL = '/media/'
111 ########## END MEDIA CONFIGURATION
114 ########## STATIC FILE CONFIGURATION
116 # See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS
118 normpath(join(DJANGO_ROOT, 'assets')),
121 # See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-finders
122 STATICFILES_FINDERS = (
123 'django.contrib.staticfiles.finders.FileSystemFinder',
124 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
125 'compressor.finders.CompressorFinder',
127 ########## END STATIC FILE CONFIGURATION
130 ########## SECRET CONFIGURATION
131 # See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
132 SECRET_KEY = r"(s1k!&^7l28k&nrm2ek(qqo&19%y(zn#=^zq_*ur2@irjun0x4"
133 ########## END SECRET CONFIGURATION
136 ########## FIXTURE CONFIGURATION
137 # See: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FIXTURE_DIRS
139 normpath(join(DJANGO_ROOT, 'fixtures')),
141 ########## END FIXTURE CONFIGURATION
144 ########## TEMPLATE CONFIGURATION
145 # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors
146 TEMPLATE_CONTEXT_PROCESSORS = (
147 'django.contrib.auth.context_processors.auth',
148 'django.core.context_processors.debug',
149 'django.core.context_processors.i18n',
150 'django.core.context_processors.media',
151 'django.core.context_processors.static',
152 'django.core.context_processors.tz',
153 'django.contrib.messages.context_processors.messages',
154 'django.core.context_processors.request',
155 'karmaworld.apps.notes.context_processors.s3_url',
157 # allauth specific context processors
158 "allauth.account.context_processors.account",
159 "allauth.socialaccount.context_processors.socialaccount",
162 # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-loaders
164 'django.template.loaders.filesystem.Loader',
165 'django.template.loaders.app_directories.Loader',
168 # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs
170 normpath(join(DJANGO_ROOT, 'templates')),
172 ########## END TEMPLATE CONFIGURATION
175 ########## MIDDLEWARE CONFIGURATION
176 # See: https://docs.djangoproject.com/en/dev/ref/settings/#middleware-classes
177 MIDDLEWARE_CLASSES = (
178 # Use GZip compression to reduce bandwidth.
179 'django.middleware.gzip.GZipMiddleware',
181 # Default Django middleware.
182 'django.middleware.common.CommonMiddleware',
183 'django.contrib.sessions.middleware.SessionMiddleware',
184 'django.middleware.csrf.CsrfViewMiddleware',
185 'django.contrib.auth.middleware.AuthenticationMiddleware',
186 'django.contrib.messages.middleware.MessageMiddleware',
188 ########## END MIDDLEWARE CONFIGURATION
191 ########## URL CONFIGURATION
192 # See: https://docs.djangoproject.com/en/dev/ref/settings/#root-urlconf
193 ROOT_URLCONF = '%s.urls' % SITE_NAME
194 ########## END URL CONFIGURATION
197 ########## APP CONFIGURATION
199 # Default Django apps:
200 'django.contrib.auth',
201 'django.contrib.contenttypes',
202 'django.contrib.sessions',
203 'django.contrib.sites',
204 'django.contrib.messages',
205 'django.contrib.staticfiles',
207 # Useful template tags:
208 'django.contrib.humanize',
210 # grappelli django-admin improvment, must be added before admin
213 # Admin panel and documentation:
214 'django.contrib.admin',
215 'django.contrib.admindocs',
219 # Database migration helpers:
222 # Static file management:
225 # Asynchronous task queue:
228 # Tagging https://github.com/yedpodtrzitko/django-taggit
233 'allauth.socialaccount',
234 # ... include the providers you want to enable:
235 'allauth.socialaccount.providers.facebook',
236 'allauth.socialaccount.providers.google',
237 'allauth.socialaccount.providers.twitter',
242 'karmaworld.apps.notes',
243 'karmaworld.apps.courses',
244 'karmaworld.apps.document_upload',
245 'karmaworld.apps.users',
246 'karmaworld.apps.moderation',
247 'karmaworld.apps.licenses',
250 # See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
251 INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
252 ########## END APP CONFIGURATION
255 ########## AUTHENTICATION
257 AUTHENTICATION_BACKENDS = (
258 # Needed to login by username in Django admin, regardless of `allauth`
259 "django.contrib.auth.backends.ModelBackend",
261 # `allauth` specific authentication methods, such as login by e-mail
262 "allauth.account.auth_backends.AuthenticationBackend",
265 ACCOUNT_EMAIL_REQUIRED = True
266 ACCOUNT_AUTHENTICATION_METHOD = "email"
267 ACCOUNT_CONFIRM_EMAIL_ON_GET = False
268 ACCOUNT_EMAIL_VERIFICATION = "optional"
269 ACCOUNT_EMAIL_SUBJECT_PREFIX = "KarmaNotes.org -- "
270 ACCOUNT_USERNAME_REQUIRED = True
271 SOCIALACCOUNT_EMAIL_REQUIRED = True
272 SOCIALACCOUNT_EMAIL_VERIFICATION = "optional"
273 SOCIALACCOUNT_QUERY_EMAIL = True
274 SOCIALACCOUNT_AUTO_SIGNUP = False
275 ACCOUNT_USER_DISPLAY = 'karmaworld.apps.users.models.user_display_name'
276 ACCOUNT_SIGNUP_FORM_CLASS = 'karmaworld.apps.users.forms.SignupForm'
278 AUTH_PROFILE_MODULE = 'users.UserProfile'
280 ######### END AUTHENTICATION
282 ########## LOGGING CONFIGURATION
283 # See: https://docs.djangoproject.com/en/dev/ref/settings/#logging
286 'disable_existing_loggers': False,
288 'require_debug_false': {
289 '()': 'django.utils.log.RequireDebugFalse'
295 'class': 'logging.StreamHandler'
299 'filters': ['require_debug_false'],
300 'class': 'django.utils.log.AdminEmailHandler'
305 'handlers': ['console'],
309 'handlers': ['mail_admins'],
315 ########## END LOGGING CONFIGURATION
318 ########## CELERY CONFIGURATION
319 # See: http://celery.readthedocs.org/en/latest/configuration.html#celery-task-result-expires
320 CELERY_TASK_RESULT_EXPIRES = timedelta(minutes=30)
322 # See: http://celery.github.com/celery/django/
324 ########## END CELERY CONFIGURATION
327 ########## WSGI CONFIGURATION
328 # See: https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application
329 WSGI_APPLICATION = 'wsgi.application'
330 ########## END WSGI CONFIGURATION
333 ########## COMPRESSION CONFIGURATION
334 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_ENABLED
335 COMPRESS_ENABLED = True
337 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_CSS_FILTERS
338 COMPRESS_CSS_FILTERS = [
339 'compressor.filters.template.TemplateFilter',
342 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_JS_FILTERS
343 COMPRESS_JS_FILTERS = [
344 'compressor.filters.template.TemplateFilter',
346 ########## END COMPRESSION CONFIGURATION
348 ########## SESSION CONFIGURATION
350 SESSION_ENGINE = 'django.contrib.sessions.backends.db'
351 SESSION_COOKIE_AGE = 63072000 # 2 years in seconds
353 ########## END SESSION CONFIGURATION
355 ########## TAGGIT CONFIGURATION
356 # From https://github.com/yedpodtrzitko/django-taggit
359 TAGGIT_FORCE_LOWERCASE = True
361 # Ignore common stopwords
362 TAGGIT_STOPWORDS = [u'a', u'an', u'and', u'be', u'from', u'of']
364 ########## END TAGGIT CONFIGURATION