Merge branch 'master' into quizzes
[oweals/karmaworld.git] / karmaworld / settings / common.py
index bfc6fb199f563c1975aa8ae10e3eb0d74a0c7cc4..80f30128d0d9d1b3ad2733d14f3d5c1bf04ce013 100644 (file)
@@ -14,6 +14,22 @@ from karmaworld.secret.filepicker import FILEPICKER_API_KEY as fp_api
 
 FILEPICKER_API_KEY = fp_api
 
+from karmaworld.secret.static_s3 import *
+
+SERIALIZATION_MODULES = {'json-pretty': 'karmaworld.apps.serializers.json_pretty'}
+
+
+########## REQUIRED SECURITY CONFIGURATION
+# See: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-ALLOWED_HOSTS
+# The hosts that this server runs from.
+ALLOWED_HOSTS = [
+    '127.0.0.1', # for dev systems / VMs, but should be safe enough
+    'localhost', # for dev systems / VMs, but should be safe enough
+    'beta.karmanotes.org',
+    'www.karmanotes.org',
+    'karmanotes.org',
+]
+########## END SECURITY CONFIGURATION
 
 ########## PATH CONFIGURATION
 # Absolute filesystem path to the Django project directory:
@@ -136,6 +152,11 @@ TEMPLATE_CONTEXT_PROCESSORS = (
     'django.core.context_processors.tz',
     'django.contrib.messages.context_processors.messages',
     'django.core.context_processors.request',
+    'karmaworld.apps.notes.context_processors.s3_url',
+
+    # allauth specific context processors
+    "allauth.account.context_processors.account",
+    "allauth.socialaccount.context_processors.socialaccount",
 )
 
 # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-loaders
@@ -157,6 +178,9 @@ MIDDLEWARE_CLASSES = (
     # Use GZip compression to reduce bandwidth.
     'django.middleware.gzip.GZipMiddleware',
 
+    # Version control middleware.
+    'reversion.middleware.RevisionMiddleware',
+
     # Default Django middleware.
     'django.middleware.common.CommonMiddleware',
     'django.contrib.sessions.middleware.SessionMiddleware',
@@ -206,6 +230,20 @@ THIRD_PARTY_APPS = (
 
     # Tagging https://github.com/yedpodtrzitko/django-taggit
     'taggit',
+
+    # Version control
+    'reversion',
+
+    'allauth',
+    'allauth.account',
+    'allauth.socialaccount',
+    # ... include the providers you want to enable:
+    'allauth.socialaccount.providers.facebook',
+    'allauth.socialaccount.providers.google',
+    'allauth.socialaccount.providers.twitter',
+
+    # Added to make quizzes moderation nicer
+    'nested_inlines',
 )
 
 LOCAL_APPS = (
@@ -216,6 +254,7 @@ LOCAL_APPS = (
     'karmaworld.apps.users',
     'karmaworld.apps.moderation',
     'karmaworld.apps.licenses',
+    'karmaworld.apps.quizzes',
 )
 
 # See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
@@ -223,11 +262,44 @@ INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
 ########## END APP CONFIGURATION
 
 
+########## AUTHENTICATION
+
+AUTHENTICATION_BACKENDS = (
+    # Needed to login by username in Django admin, regardless of `allauth`
+    "django.contrib.auth.backends.ModelBackend",
+
+    # `allauth` specific authentication methods, such as login by e-mail
+    "allauth.account.auth_backends.AuthenticationBackend",
+)
+
+ACCOUNT_EMAIL_REQUIRED = True
+ACCOUNT_AUTHENTICATION_METHOD = "email"
+ACCOUNT_CONFIRM_EMAIL_ON_GET = False
+ACCOUNT_EMAIL_VERIFICATION = "optional"
+ACCOUNT_EMAIL_SUBJECT_PREFIX = "KarmaNotes.org -- "
+ACCOUNT_USERNAME_REQUIRED = True
+SOCIALACCOUNT_EMAIL_REQUIRED = True
+SOCIALACCOUNT_EMAIL_VERIFICATION = "optional"
+SOCIALACCOUNT_QUERY_EMAIL = True
+SOCIALACCOUNT_AUTO_SIGNUP = False
+ACCOUNT_USER_DISPLAY = 'karmaworld.apps.users.models.user_display_name'
+ACCOUNT_SIGNUP_FORM_CLASS = 'karmaworld.apps.users.forms.SignupForm'
+ACCOUNT_DEFAULT_HTTP_PROTOCOL = 'https'
+
+AUTH_PROFILE_MODULE = 'users.UserProfile'
+
+######### END AUTHENTICATION
+
 ########## LOGGING CONFIGURATION
 # See: https://docs.djangoproject.com/en/dev/ref/settings/#logging
 LOGGING = {
     'version': 1,
     'disable_existing_loggers': False,
+    'filters': {
+         'require_debug_false': {
+             '()': 'django.utils.log.RequireDebugFalse'
+         }
+     },
     'handlers': {
         'console': {
             'level': 'INFO',
@@ -235,6 +307,7 @@ LOGGING = {
         },
         'mail_admins': {
             'level': 'ERROR',
+            'filters': ['require_debug_false'],
             'class': 'django.utils.log.AdminEmailHandler'
         }
     },
@@ -285,6 +358,7 @@ COMPRESS_JS_FILTERS = [
 
 ########## SESSION CONFIGURATION
 
+SESSION_ENGINE = 'django.contrib.sessions.backends.db'
 SESSION_COOKIE_AGE = 63072000    # 2 years in seconds
 
 ########## END SESSION CONFIGURATION