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 # Version control middleware.
182 'reversion.middleware.RevisionMiddleware',
184 # Default Django middleware.
185 'django.middleware.common.CommonMiddleware',
186 'django.contrib.sessions.middleware.SessionMiddleware',
187 'django.middleware.csrf.CsrfViewMiddleware',
188 'django.contrib.auth.middleware.AuthenticationMiddleware',
189 'django.contrib.messages.middleware.MessageMiddleware',
191 ########## END MIDDLEWARE CONFIGURATION
194 ########## URL CONFIGURATION
195 # See: https://docs.djangoproject.com/en/dev/ref/settings/#root-urlconf
196 ROOT_URLCONF = '%s.urls' % SITE_NAME
197 ########## END URL CONFIGURATION
200 ########## APP CONFIGURATION
202 # Default Django apps:
203 'django.contrib.auth',
204 'django.contrib.contenttypes',
205 'django.contrib.sessions',
206 'django.contrib.sites',
207 'django.contrib.messages',
208 'django.contrib.staticfiles',
210 # Useful template tags:
211 'django.contrib.humanize',
213 # grappelli django-admin improvment, must be added before admin
216 # Admin panel and documentation:
217 'django.contrib.admin',
218 'django.contrib.admindocs',
222 # Database migration helpers:
225 # Static file management:
228 # Asynchronous task queue:
231 # Tagging https://github.com/yedpodtrzitko/django-taggit
239 'allauth.socialaccount',
240 # ... include the providers you want to enable:
241 'allauth.socialaccount.providers.facebook',
242 'allauth.socialaccount.providers.google',
243 'allauth.socialaccount.providers.twitter',
245 # Added to make quizzes moderation nicer
251 'karmaworld.apps.notes',
252 'karmaworld.apps.courses',
253 'karmaworld.apps.document_upload',
254 'karmaworld.apps.users',
255 'karmaworld.apps.moderation',
256 'karmaworld.apps.licenses',
257 'karmaworld.apps.quizzes',
260 # See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
261 INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
262 ########## END APP CONFIGURATION
265 ########## AUTHENTICATION
267 AUTHENTICATION_BACKENDS = (
268 # Needed to login by username in Django admin, regardless of `allauth`
269 "django.contrib.auth.backends.ModelBackend",
271 # `allauth` specific authentication methods, such as login by e-mail
272 "allauth.account.auth_backends.AuthenticationBackend",
275 ACCOUNT_EMAIL_REQUIRED = True
276 ACCOUNT_AUTHENTICATION_METHOD = "email"
277 ACCOUNT_CONFIRM_EMAIL_ON_GET = False
278 ACCOUNT_EMAIL_VERIFICATION = "optional"
279 ACCOUNT_EMAIL_SUBJECT_PREFIX = "KarmaNotes.org -- "
280 ACCOUNT_USERNAME_REQUIRED = True
281 SOCIALACCOUNT_EMAIL_REQUIRED = True
282 SOCIALACCOUNT_EMAIL_VERIFICATION = "optional"
283 SOCIALACCOUNT_QUERY_EMAIL = True
284 SOCIALACCOUNT_AUTO_SIGNUP = False
285 ACCOUNT_USER_DISPLAY = 'karmaworld.apps.users.models.user_display_name'
286 ACCOUNT_SIGNUP_FORM_CLASS = 'karmaworld.apps.users.forms.SignupForm'
287 ACCOUNT_DEFAULT_HTTP_PROTOCOL = 'https'
289 AUTH_PROFILE_MODULE = 'users.UserProfile'
291 ######### END AUTHENTICATION
293 ########## LOGGING CONFIGURATION
294 # See: https://docs.djangoproject.com/en/dev/ref/settings/#logging
297 'disable_existing_loggers': False,
299 'require_debug_false': {
300 '()': 'django.utils.log.RequireDebugFalse'
306 'class': 'logging.StreamHandler'
310 'filters': ['require_debug_false'],
311 'class': 'django.utils.log.AdminEmailHandler'
316 'handlers': ['console'],
320 'handlers': ['mail_admins'],
326 ########## END LOGGING CONFIGURATION
329 ########## CELERY CONFIGURATION
330 # See: http://celery.readthedocs.org/en/latest/configuration.html#celery-task-result-expires
331 CELERY_TASK_RESULT_EXPIRES = timedelta(minutes=30)
333 # See: http://celery.github.com/celery/django/
335 ########## END CELERY CONFIGURATION
338 ########## WSGI CONFIGURATION
339 # See: https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application
340 WSGI_APPLICATION = 'wsgi.application'
341 ########## END WSGI CONFIGURATION
344 ########## COMPRESSION CONFIGURATION
345 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_ENABLED
346 COMPRESS_ENABLED = True
348 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_CSS_FILTERS
349 COMPRESS_CSS_FILTERS = [
350 'compressor.filters.template.TemplateFilter',
353 # See: http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_JS_FILTERS
354 COMPRESS_JS_FILTERS = [
355 'compressor.filters.template.TemplateFilter',
357 ########## END COMPRESSION CONFIGURATION
359 ########## SESSION CONFIGURATION
361 SESSION_ENGINE = 'django.contrib.sessions.backends.db'
362 SESSION_COOKIE_AGE = 63072000 # 2 years in seconds
364 ########## END SESSION CONFIGURATION
366 ########## TAGGIT CONFIGURATION
367 # From https://github.com/yedpodtrzitko/django-taggit
370 TAGGIT_FORCE_LOWERCASE = True
372 # Ignore common stopwords
373 TAGGIT_STOPWORDS = [u'a', u'an', u'and', u'be', u'from', u'of']
375 ########## END TAGGIT CONFIGURATION