X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=karmaworld%2Fsettings%2Fcommon.py;h=5792d31c159e56729591167e6de803088f19e637;hb=943c481f1b9f8ca6636adb4ba82abbf6599def4b;hp=692e3be54055456b261fcd02ea9b4432e5148a3d;hpb=dea608ca03981fa5ab6fc1a2a0862b6263e4258d;p=oweals%2Fkarmaworld.git diff --git a/karmaworld/settings/common.py b/karmaworld/settings/common.py index 692e3be..5792d31 100644 --- a/karmaworld/settings/common.py +++ b/karmaworld/settings/common.py @@ -5,6 +5,7 @@ from datetime import timedelta +import sys from os.path import abspath, basename, dirname, join, normpath from sys import path @@ -13,7 +14,25 @@ from djcelery import setup_loader from karmaworld.secret.filepicker import FILEPICKER_API_KEY as fp_api FILEPICKER_API_KEY = fp_api +FILEPICKER_INPUT_TYPE = 'filepicker' +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', + 'quiz.karmanotes.org', +] +########## END SECURITY CONFIGURATION ########## PATH CONFIGURATION # Absolute filesystem path to the Django project directory: @@ -136,6 +155,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 +181,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 +233,24 @@ THIRD_PARTY_APPS = ( # Tagging https://github.com/yedpodtrzitko/django-taggit 'taggit', + + # Version control + 'reversion', + + # AJAX endpoints for autocompletion + 'ajax_select', + 'ajax_select_cascade', + + '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 = ( @@ -213,7 +258,10 @@ LOCAL_APPS = ( 'karmaworld.apps.notes', 'karmaworld.apps.courses', 'karmaworld.apps.document_upload', - 'karmaworld.apps.users' + 'karmaworld.apps.users', + 'karmaworld.apps.moderation', + 'karmaworld.apps.licenses', + 'karmaworld.apps.quizzes', ) # See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps @@ -221,11 +269,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', @@ -233,6 +314,7 @@ LOGGING = { }, 'mail_admins': { 'level': 'ERROR', + 'filters': ['require_debug_false'], 'class': 'django.utils.log.AdminEmailHandler' } }, @@ -281,6 +363,13 @@ COMPRESS_JS_FILTERS = [ ] ########## END COMPRESSION CONFIGURATION +########## SESSION CONFIGURATION + +SESSION_ENGINE = 'django.contrib.sessions.backends.db' +SESSION_COOKIE_AGE = 63072000 # 2 years in seconds + +########## END SESSION CONFIGURATION + ########## TAGGIT CONFIGURATION # From https://github.com/yedpodtrzitko/django-taggit @@ -292,3 +381,17 @@ TAGGIT_STOPWORDS = [u'a', u'an', u'and', u'be', u'from', u'of'] ########## END TAGGIT CONFIGURATION + +########## HONEYPOT CONFIGURATION +# parts of this code borrow from +# https://github.com/sunlightlabs/django-honeypot +HONEYPOT_FIELD_NAME = "instruction_url" # see that "_url"? bots gotta want that. +HONEYPOT_VALUE = "" +HONEYPOT_LABEL = "Do not fill in this field (we need to make sure you're not a robot)" +HONEYPOT_ERROR = "You did not follow directions." +########## END HONEYPOT CONFIGURATION + + +########## TESTING CONFIGURATION +TESTING = 'test' in sys.argv +########## END TESTING CONFIGURATION