sanitize settings
authorJan Szejko <jan.szejko@gmail.com>
Fri, 20 May 2016 15:19:20 +0000 (17:19 +0200)
committerJan Szejko <jan.szejko@gmail.com>
Fri, 20 May 2016 15:19:58 +0000 (17:19 +0200)
29 files changed:
edumed/settings.d/10-paths.py [deleted file]
edumed/settings.d/20-basic.py [deleted file]
edumed/settings.d/30-apps.py [deleted file]
edumed/settings.d/30-locale.py [deleted file]
edumed/settings.d/35-search.py [deleted file]
edumed/settings.d/40-auth.py [deleted file]
edumed/settings.d/40-cache.py [deleted file]
edumed/settings.d/40-context.py [deleted file]
edumed/settings.d/40-logging.py [deleted file]
edumed/settings.d/40-middleware.py [deleted file]
edumed/settings.d/50-contrib.py [deleted file]
edumed/settings.d/50-static.py [deleted file]
edumed/settings.d/60-custom.py [deleted file]
edumed/settings.py [deleted file]
edumed/settings/__init__.py [new file with mode: 0644]
edumed/settings/apps.py [new file with mode: 0644]
edumed/settings/auth.py [new file with mode: 0644]
edumed/settings/basic.py [new file with mode: 0644]
edumed/settings/cache.py [new file with mode: 0644]
edumed/settings/context.py [new file with mode: 0644]
edumed/settings/contrib.py [new file with mode: 0644]
edumed/settings/custom.py [new file with mode: 0644]
edumed/settings/locale.py [new file with mode: 0644]
edumed/settings/logging.py [new file with mode: 0644]
edumed/settings/middleware.py [new file with mode: 0644]
edumed/settings/paths.py [new file with mode: 0644]
edumed/settings/search.py [new file with mode: 0644]
edumed/settings/static.py [new file with mode: 0644]
edumed/utils.py

diff --git a/edumed/settings.d/10-paths.py b/edumed/settings.d/10-paths.py
deleted file mode 100644 (file)
index b3ef304..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-from os import path
-
-PROJECT_DIR = path.dirname(path.abspath(path.dirname(__file__)))
diff --git a/edumed/settings.d/20-basic.py b/edumed/settings.d/20-basic.py
deleted file mode 100644 (file)
index 9d0a384..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-DEBUG = False
-TEMPLATE_DEBUG = DEBUG
-
-DATABASES = {
-    'default': {
-        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
-        'NAME': path.join(PROJECT_DIR, 'dev.db'),                      # Or path to database file if using sqlite3.
-        'USER': '',                      # Not used with sqlite3.
-        'PASSWORD': '',                  # Not used with sqlite3.
-        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
-        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
-    }
-}
-
-SITE_ID = 1
-
-# List of callables that know how to import templates from various sources.
-TEMPLATE_LOADERS = (
-    'django.template.loaders.filesystem.Loader',
-    'django.template.loaders.app_directories.Loader',
-#     'django.template.loaders.eggs.Loader',
-)
-
-ROOT_URLCONF = 'edumed.urls'
-
-SUBDOMAIN_URLCONFS = {
-    None: 'edumed.urls',
-    'katalog': 'edumed.milurls',
-}
-
-# Python dotted path to the WSGI application used by Django's runserver.
-WSGI_APPLICATION = 'edumed.wsgi.application'
-
-TEMPLATE_DIRS = (
-    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
-    # Always use forward slashes, even on Windows.
-    # Don't forget to use absolute paths, not relative paths.
-)
diff --git a/edumed/settings.d/30-apps.py b/edumed/settings.d/30-apps.py
deleted file mode 100644 (file)
index a5b9c97..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-INSTALLED_APPS = (
-    'edumed',
-    'curriculum',
-    'catalogue',
-    'comment',
-    'wtem',
-    'publishers',
-    'api'
-
-    'fnpdjango',
-    'south',
-    'pipeline',
-    'django_extensions',
-    # Disable, if not using Piwik.
-    'piwik',
-    # Disable, if not using CAS.
-    'honeypot',
-    'django_cas',
-    'sponsors',
-    'haystack',
-    'chunks',
-    'contact',
-    'forum',
-    'pybb',
-    'django_libravatar',
-    'sorl.thumbnail',
-    'subdomains',
-
-    'django.contrib.auth',
-    'django.contrib.contenttypes',
-    'django.contrib.sessions',
-    'django.contrib.sites',
-    'django.contrib.messages',
-    'django.contrib.staticfiles',
-    'django.contrib.admin',
-    'django.contrib.admindocs',
-    'django.contrib.flatpages',
-    'django.contrib.humanize'
-)
diff --git a/edumed/settings.d/30-locale.py b/edumed/settings.d/30-locale.py
deleted file mode 100644 (file)
index ed2173a..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-# -*- coding: utf-8 -*-
-
-LANGUAGES = (
-    ('pl', u'polski'),
-    ('en', u'English'),
-)
-
-# Local time zone for this installation. Choices can be found here:
-# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
-# although not all choices may be available on all operating systems.
-# On Unix systems, a value of None will cause Django to use the same
-# timezone as the operating system.
-# If running in a Windows environment this must be set to the same as your
-# system time zone.
-TIME_ZONE = None
-
-# Language code for this installation. All choices can be found here:
-# http://www.i18nguy.com/unicode/language-identifiers.html
-LANGUAGE_CODE = 'pl'
-
-# If you set this to False, Django will make some optimizations so as not
-# to load the internationalization machinery.
-USE_I18N = True
-
-# If you set this to False, Django will not format dates, numbers and
-# calendars according to the current locale.
-USE_L10N = True
-
-# If you set this to False, Django will not use timezone-aware datetimes.
-USE_TZ = True
-
-CONTRIB_LOCALE_APPS = (
-    'pybb',
-)
-LOCALE_PATHS = (
-    path.join(PROJECT_DIR, 'edumed/locale-contrib'),
-)
diff --git a/edumed/settings.d/35-search.py b/edumed/settings.d/35-search.py
deleted file mode 100644 (file)
index bfc6f28..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-HAYSTACK_CONNECTIONS = {
-    'default': {
-        'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
-        'URL': 'http://127.0.0.1:8983/solr/edumed'
-    },
-}
diff --git a/edumed/settings.d/40-auth.py b/edumed/settings.d/40-auth.py
deleted file mode 100644 (file)
index 14847ac..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-if 'django_cas' in INSTALLED_APPS:
-    AUTHENTICATION_BACKENDS = (
-        'django.contrib.auth.backends.ModelBackend',
-        'fnpdjango.auth_backends.AttrCASBackend',
-    )
diff --git a/edumed/settings.d/40-cache.py b/edumed/settings.d/40-cache.py
deleted file mode 100644 (file)
index d6d903e..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-CACHES = {
-    'default': {
-        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
-        'LOCATION': '127.0.0.1:11211',
-        'KEY_PREFIX': 'edumed',
-    }
-}
-
-CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True
diff --git a/edumed/settings.d/40-context.py b/edumed/settings.d/40-context.py
deleted file mode 100644 (file)
index 6e43646..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-TEMPLATE_CONTEXT_PROCESSORS = tuple(x for x in (
-    "django.contrib.auth.context_processors.auth"
-            if "django.contrib.auth" in INSTALLED_APPS else None,
-    "django.core.context_processors.debug",
-    "django.core.context_processors.i18n",
-    "django.core.context_processors.media",
-    "django.core.context_processors.static",
-    "django.core.context_processors.tz",
-    "django.contrib.messages.context_processors.messages"
-            if 'django.contrib.messages' in INSTALLED_APPS else None,
-    "django.core.context_processors.request",
-    'pybb.context_processors.processor',
-    'edumed.context_processors.base_template'
-) if x is not None)
diff --git a/edumed/settings.d/40-logging.py b/edumed/settings.d/40-logging.py
deleted file mode 100644 (file)
index 3d91c9c..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-# A sample logging configuration. The only tangible logging
-# performed by this configuration is to send an email to
-# the site admins on every HTTP 500 error when DEBUG=False.
-# See http://docs.djangoproject.com/en/dev/topics/logging for
-# more details on how to customize your logging configuration.
-LOGGING = {
-    'version': 1,
-    'disable_existing_loggers': False,
-    'filters': {
-        'require_debug_false': {
-            '()': 'django.utils.log.RequireDebugFalse'
-        }
-    },
-    'handlers': {
-        'mail_admins': {
-            'level': 'ERROR',
-            'filters': ['require_debug_false'],
-            'class': 'django.utils.log.AdminEmailHandler'
-        }
-    },
-    'loggers': {
-        'django.request': {
-            'handlers': ['mail_admins'],
-            'level': 'ERROR',
-            'propagate': True,
-        },
-    }
-}
diff --git a/edumed/settings.d/40-middleware.py b/edumed/settings.d/40-middleware.py
deleted file mode 100644 (file)
index 6175197..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-MIDDLEWARE_CLASSES = tuple(x for x in (
-    'django.middleware.cache.UpdateCacheMiddleware',
-    'django.contrib.sessions.middleware.SessionMiddleware'
-            if "django.contrib.sessions" in INSTALLED_APPS else None,
-    #'django.middleware.locale.LocaleMiddleware',
-    'subdomains.middleware.SubdomainURLRoutingMiddleware',
-    'fnpdjango.middleware.URLLocaleMiddleware',
-
-    'django.middleware.common.CommonMiddleware',
-    'django.middleware.csrf.CsrfViewMiddleware',
-    'honeypot.middleware.HoneypotMiddleware',
-    'django.contrib.auth.middleware.AuthenticationMiddleware'
-            if "django.contrib.auth" in INSTALLED_APPS else None,
-    'django_cas.middleware.CASMiddleware'
-            if "django_cas" in INSTALLED_APPS else None,
-    'django.contrib.messages.middleware.MessageMiddleware'
-            if "django.contrib.messages" in INSTALLED_APPS else None,
-    # Uncomment the next line for simple clickjacking protection:
-    # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
-    'pagination.middleware.PaginationMiddleware'
-            if "pagination" in INSTALLED_APPS else None,
-    'django.middleware.cache.FetchFromCacheMiddleware',
-    'fnpdjango.middleware.SetRemoteAddrFromXRealIP',
-    'pybb.middleware.PybbMiddleware',
-    'forum.middleware.ForumMiddleware',
-    'wtem.middleware.ThreadLocalMiddleware'
-) if x is not None)
diff --git a/edumed/settings.d/50-contrib.py b/edumed/settings.d/50-contrib.py
deleted file mode 100644 (file)
index 9306de1..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-CAS_SERVER_URL = 'http://logowanie.nowoczesnapolska.org.pl/cas/'
-CAS_VERSION = '3'
-
-SPONSORS_THUMB_WIDTH = 100
-SPONSORS_THUMB_HEIGHT = 56
-
-PYBB_TEMPLATE = "base_forum.html"
-PYBB_SMILES = {}
-PYBB_ENABLE_ANONYMOUS_POST = False
-
-PYBB_DEFAULT_TITLE = u'Forum'
-PYBB_DEFAULT_TIME_ZONE = 1
-PYBB_PERMISSION_HANDLER = 'edumed.forum.ForumPermissionHandler'
-
-THUMBNAIL_ENGINE = 'sorl.thumbnail.engines.convert_engine.Engine'
-THUMBNAIL_CONVERT = 'convert -density 300 -background white -alpha off'
diff --git a/edumed/settings.d/50-static.py b/edumed/settings.d/50-static.py
deleted file mode 100644 (file)
index c667c32..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-MEDIA_ROOT = path.join(PROJECT_DIR, 'media/')
-MEDIA_URL = '/media/'
-STATIC_ROOT = path.join(PROJECT_DIR, 'static/')
-STATIC_URL = '/static/'
-
-STATICFILES_FINDERS = (
-    'django.contrib.staticfiles.finders.FileSystemFinder',
-    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
-#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
-)
-
-STATICFILES_STORAGE = 'fnpdjango.utils.pipeline_storage.GzipPipelineCachedStorage'
-PIPELINE_CSS_COMPRESSOR = None
-PIPELINE_JS_COMPRESSOR = None
-PIPELINE_CSS = {
-    'base': {
-        'source_filenames': (
-          'css/base.scss',
-          'css/main.scss',
-          'css/form.scss',
-          'catalogue/css/carousel.scss',
-          'catalogue/css/layout.scss',
-          'catalogue/css/lesson.scss',
-          'catalogue/css/exercise.scss',
-          'catalogue/css/section_list.scss',
-          'curriculum/curriculum.scss',
-          'jquery/colorbox/colorbox.css',
-          'fnpdjango/annoy/annoy.css',
-
-          'css/forum.scss',
-          'css/mil.scss'
-        ),
-        'output_filename': 'compressed/base.css',
-    },
-}
-PIPELINE_JS = {
-    'base': {
-        'source_filenames': (
-            'catalogue/js/jquery-ui-1.10.0.custom.js',
-            'catalogue/js/jquery.cycle.all.js',
-            'jquery/colorbox/jquery.colorbox-min.js',
-            'jquery/colorbox/jquery.colorbox-pl.js',
-            'catalogue/js/carousel.js',
-            'catalogue/js/edumed.js',
-            'catalogue/js/lesson.js',
-            'catalogue/js/lesson-list.js',
-            'sponsors/js/sponsors.js',
-            'curriculum/curriculum.js',
-            'js/formset.js',
-            'pybb/js/pybbjs.js',
-            'fnpdjango/annoy/annoy.js',
-        ),
-        'output_filename': 'compressed/base.js',
-    },
-    'wtem': {
-        'source_filenames': (
-            'catalogue/js/jquery-ui-1.10.0.custom.js',
-            'wtem/edumed.js',
-            'wtem/wtem.js',
-            'wtem/json2.js'
-        ),
-        'output_filename': 'compressed/wtem.js'
-    },
-}
-
-PIPELINE_COMPILERS = (
-  'pipeline.compilers.sass.SASSCompiler',
-)
diff --git a/edumed/settings.d/60-custom.py b/edumed/settings.d/60-custom.py
deleted file mode 100644 (file)
index 869e6f4..0000000
+++ /dev/null
@@ -1 +0,0 @@
-CONTACT_FORMS_MODULE = 'edumed.contact_forms'
diff --git a/edumed/settings.py b/edumed/settings.py
deleted file mode 100644 (file)
index c5df1a7..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-# -*- coding: utf-8 -*-
-import os.path
-import glob
-
-conffiles = glob.glob(os.path.join(
-    os.path.dirname(__file__), 'settings.d', '*.py'))
-conffiles.sort()
-for f in conffiles:
-    execfile(os.path.abspath(f))
-
-try:
-    execfile(os.path.abspath(os.path.join(
-        os.path.dirname(__file__), 'localsettings.py')))
-except IOError:
-    pass
diff --git a/edumed/settings/__init__.py b/edumed/settings/__init__.py
new file mode 100644 (file)
index 0000000..4a75df0
--- /dev/null
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+
+from .paths import *
+from .basic import *
+from .apps import *
+from .locale import *
+from .search import *
+from .auth import *
+from .cache import *
+from .context import *
+from .logging import *
+from .middleware import *
+from .contrib import *
+from .static import *
+from .custom import *
+
+# Load localsettings, if they exist
+try:
+    from edumed.localsettings import *
+except ImportError:
+    pass
\ No newline at end of file
diff --git a/edumed/settings/apps.py b/edumed/settings/apps.py
new file mode 100644 (file)
index 0000000..ca243c9
--- /dev/null
@@ -0,0 +1,41 @@
+# -*- coding: utf-8 -*-
+
+INSTALLED_APPS = (
+    'edumed',
+    'curriculum',
+    'catalogue',
+    'comment',
+    'wtem',
+    'publishers',
+    'api',
+
+    'fnpdjango',
+    'south',
+    'pipeline',
+    'django_extensions',
+    # Disable, if not using Piwik.
+    'piwik',
+    # Disable, if not using CAS.
+    'honeypot',
+    'django_cas',
+    'sponsors',
+    'haystack',
+    'chunks',
+    'contact',
+    'forum',
+    'pybb',
+    'django_libravatar',
+    'sorl.thumbnail',
+    'subdomains',
+
+    'django.contrib.auth',
+    'django.contrib.contenttypes',
+    'django.contrib.sessions',
+    'django.contrib.sites',
+    'django.contrib.messages',
+    'django.contrib.staticfiles',
+    'django.contrib.admin',
+    'django.contrib.admindocs',
+    'django.contrib.flatpages',
+    'django.contrib.humanize'
+)
diff --git a/edumed/settings/auth.py b/edumed/settings/auth.py
new file mode 100644 (file)
index 0000000..35c74c4
--- /dev/null
@@ -0,0 +1,8 @@
+# -*- coding: utf-8 -*-
+from .apps import INSTALLED_APPS
+
+if 'django_cas' in INSTALLED_APPS:
+    AUTHENTICATION_BACKENDS = (
+        'django.contrib.auth.backends.ModelBackend',
+        'fnpdjango.auth_backends.AttrCASBackend',
+    )
diff --git a/edumed/settings/basic.py b/edumed/settings/basic.py
new file mode 100644 (file)
index 0000000..3e553b3
--- /dev/null
@@ -0,0 +1,43 @@
+# -*- coding: utf-8 -*-
+import os.path
+
+from .paths import PROJECT_DIR
+
+DEBUG = False
+TEMPLATE_DEBUG = DEBUG
+
+DATABASES = {
+    'default': {
+        'ENGINE': 'django.db.backends.sqlite3',  # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
+        'NAME': os.path.join(PROJECT_DIR, 'dev.db'),                      # Or path to database file if using sqlite3.
+        'USER': '',                      # Not used with sqlite3.
+        'PASSWORD': '',                  # Not used with sqlite3.
+        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
+        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
+    }
+}
+
+SITE_ID = 1
+
+# List of callables that know how to import templates from various sources.
+TEMPLATE_LOADERS = (
+    'django.template.loaders.filesystem.Loader',
+    'django.template.loaders.app_directories.Loader',
+    # 'django.template.loaders.eggs.Loader',
+)
+
+ROOT_URLCONF = 'edumed.urls'
+
+SUBDOMAIN_URLCONFS = {
+    None: 'edumed.urls',
+    'katalog': 'edumed.milurls',
+}
+
+# Python dotted path to the WSGI application used by Django's runserver.
+WSGI_APPLICATION = 'edumed.wsgi.application'
+
+TEMPLATE_DIRS = (
+    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
+    # Always use forward slashes, even on Windows.
+    # Don't forget to use absolute paths, not relative paths.
+)
diff --git a/edumed/settings/cache.py b/edumed/settings/cache.py
new file mode 100644 (file)
index 0000000..3079b6c
--- /dev/null
@@ -0,0 +1,11 @@
+# -*- coding: utf-8 -*-
+
+CACHES = {
+    'default': {
+        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
+        'LOCATION': '127.0.0.1:11211',
+        'KEY_PREFIX': 'edumed',
+    }
+}
+
+CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True
diff --git a/edumed/settings/context.py b/edumed/settings/context.py
new file mode 100644 (file)
index 0000000..bff5838
--- /dev/null
@@ -0,0 +1,15 @@
+# -*- coding: utf-8 -*-
+from edumed.utils import process_app_deps
+
+TEMPLATE_CONTEXT_PROCESSORS = process_app_deps((
+    ("django.contrib.auth.context_processors.auth", "django.contrib.auth"),
+    "django.core.context_processors.debug",
+    "django.core.context_processors.i18n",
+    "django.core.context_processors.media",
+    "django.core.context_processors.static",
+    "django.core.context_processors.tz",
+    ("django.contrib.messages.context_processors.messages", 'django.contrib.messages'),
+    "django.core.context_processors.request",
+    'pybb.context_processors.processor',
+    'edumed.context_processors.base_template',
+))
diff --git a/edumed/settings/contrib.py b/edumed/settings/contrib.py
new file mode 100644 (file)
index 0000000..d7ea957
--- /dev/null
@@ -0,0 +1,18 @@
+# -*- coding: utf-8 -*-
+
+CAS_SERVER_URL = 'http://logowanie.nowoczesnapolska.org.pl/cas/'
+CAS_VERSION = '3'
+
+SPONSORS_THUMB_WIDTH = 100
+SPONSORS_THUMB_HEIGHT = 56
+
+PYBB_TEMPLATE = "base_forum.html"
+PYBB_SMILES = {}
+PYBB_ENABLE_ANONYMOUS_POST = False
+
+PYBB_DEFAULT_TITLE = u'Forum'
+PYBB_DEFAULT_TIME_ZONE = 1
+PYBB_PERMISSION_HANDLER = 'edumed.forum.ForumPermissionHandler'
+
+THUMBNAIL_ENGINE = 'sorl.thumbnail.engines.convert_engine.Engine'
+THUMBNAIL_CONVERT = 'convert -density 300 -background white -alpha off'
diff --git a/edumed/settings/custom.py b/edumed/settings/custom.py
new file mode 100644 (file)
index 0000000..a2fc281
--- /dev/null
@@ -0,0 +1,3 @@
+# -*- coding: utf-8 -*-
+
+CONTACT_FORMS_MODULE = 'edumed.contact_forms'
diff --git a/edumed/settings/locale.py b/edumed/settings/locale.py
new file mode 100644 (file)
index 0000000..cfe4cc1
--- /dev/null
@@ -0,0 +1,40 @@
+# -*- coding: utf-8 -*-
+import os.path
+
+from .paths import PROJECT_DIR
+
+LANGUAGES = (
+    ('pl', u'polski'),
+    ('en', u'English'),
+)
+
+# Local time zone for this installation. Choices can be found here:
+# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
+# although not all choices may be available on all operating systems.
+# On Unix systems, a value of None will cause Django to use the same
+# timezone as the operating system.
+# If running in a Windows environment this must be set to the same as your
+# system time zone.
+TIME_ZONE = None
+
+# Language code for this installation. All choices can be found here:
+# http://www.i18nguy.com/unicode/language-identifiers.html
+LANGUAGE_CODE = 'pl'
+
+# If you set this to False, Django will make some optimizations so as not
+# to load the internationalization machinery.
+USE_I18N = True
+
+# If you set this to False, Django will not format dates, numbers and
+# calendars according to the current locale.
+USE_L10N = True
+
+# If you set this to False, Django will not use timezone-aware datetimes.
+USE_TZ = True
+
+CONTRIB_LOCALE_APPS = (
+    'pybb',
+)
+LOCALE_PATHS = (
+    os.path.join(PROJECT_DIR, 'edumed/locale-contrib'),
+)
diff --git a/edumed/settings/logging.py b/edumed/settings/logging.py
new file mode 100644 (file)
index 0000000..ea3ad61
--- /dev/null
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+# A sample logging configuration. The only tangible logging
+# performed by this configuration is to send an email to
+# the site admins on every HTTP 500 error when DEBUG=False.
+# See http://docs.djangoproject.com/en/dev/topics/logging for
+# more details on how to customize your logging configuration.
+LOGGING = {
+    'version': 1,
+    'disable_existing_loggers': False,
+    'filters': {
+        'require_debug_false': {
+            '()': 'django.utils.log.RequireDebugFalse'
+        }
+    },
+    'handlers': {
+        'mail_admins': {
+            'level': 'ERROR',
+            'filters': ['require_debug_false'],
+            'class': 'django.utils.log.AdminEmailHandler'
+        }
+    },
+    'loggers': {
+        'django.request': {
+            'handlers': ['mail_admins'],
+            'level': 'ERROR',
+            'propagate': True,
+        },
+    }
+}
diff --git a/edumed/settings/middleware.py b/edumed/settings/middleware.py
new file mode 100644 (file)
index 0000000..15ab189
--- /dev/null
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+from edumed.utils import process_app_deps
+
+MIDDLEWARE_CLASSES = process_app_deps((
+    'django.middleware.cache.UpdateCacheMiddleware',
+    ('django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.sessions'),
+    # 'django.middleware.locale.LocaleMiddleware',
+    'subdomains.middleware.SubdomainURLRoutingMiddleware',
+    'fnpdjango.middleware.URLLocaleMiddleware',
+
+    'django.middleware.common.CommonMiddleware',
+    'django.middleware.csrf.CsrfViewMiddleware',
+    'honeypot.middleware.HoneypotMiddleware',
+    ('django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth'),
+    ('django_cas.middleware.CASMiddleware', 'django_cas'),
+    ('django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.messages'),
+    # Uncomment the next line for simple clickjacking protection:
+    # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
+    ('pagination.middleware.PaginationMiddleware', 'pagination'),
+    'django.middleware.cache.FetchFromCacheMiddleware',
+    'fnpdjango.middleware.SetRemoteAddrFromXRealIP',
+    'pybb.middleware.PybbMiddleware',
+    'forum.middleware.ForumMiddleware',
+    'wtem.middleware.ThreadLocalMiddleware'
+))
diff --git a/edumed/settings/paths.py b/edumed/settings/paths.py
new file mode 100644 (file)
index 0000000..55d7b9e
--- /dev/null
@@ -0,0 +1,4 @@
+# -*- coding: utf-8 -*-
+import os.path
+
+PROJECT_DIR = os.path.dirname(os.path.abspath(os.path.dirname(__file__)))
diff --git a/edumed/settings/search.py b/edumed/settings/search.py
new file mode 100644 (file)
index 0000000..f54983b
--- /dev/null
@@ -0,0 +1,8 @@
+# -*- coding: utf-8 -*-
+
+HAYSTACK_CONNECTIONS = {
+    'default': {
+        'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
+        'URL': 'http://127.0.0.1:8983/solr/edumed'
+    },
+}
diff --git a/edumed/settings/static.py b/edumed/settings/static.py
new file mode 100644 (file)
index 0000000..a2f2c05
--- /dev/null
@@ -0,0 +1,73 @@
+# -*- coding: utf-8 -*-
+import os.path
+
+from .paths import PROJECT_DIR
+
+MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media/')
+MEDIA_URL = '/media/'
+STATIC_ROOT = os.path.join(PROJECT_DIR, 'static/')
+STATIC_URL = '/static/'
+
+STATICFILES_FINDERS = (
+    'django.contrib.staticfiles.finders.FileSystemFinder',
+    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
+    # 'django.contrib.staticfiles.finders.DefaultStorageFinder',
+)
+
+STATICFILES_STORAGE = 'fnpdjango.utils.pipeline_storage.GzipPipelineCachedStorage'
+PIPELINE_CSS_COMPRESSOR = None
+PIPELINE_JS_COMPRESSOR = None
+PIPELINE_CSS = {
+    'base': {
+        'source_filenames': (
+          'css/base.scss',
+          'css/main.scss',
+          'css/form.scss',
+          'catalogue/css/carousel.scss',
+          'catalogue/css/layout.scss',
+          'catalogue/css/lesson.scss',
+          'catalogue/css/exercise.scss',
+          'catalogue/css/section_list.scss',
+          'curriculum/curriculum.scss',
+          'jquery/colorbox/colorbox.css',
+          'fnpdjango/annoy/annoy.css',
+
+          'css/forum.scss',
+          'css/mil.scss'
+        ),
+        'output_filename': 'compressed/base.css',
+    },
+}
+PIPELINE_JS = {
+    'base': {
+        'source_filenames': (
+            'catalogue/js/jquery-ui-1.10.0.custom.js',
+            'catalogue/js/jquery.cycle.all.js',
+            'jquery/colorbox/jquery.colorbox-min.js',
+            'jquery/colorbox/jquery.colorbox-pl.js',
+            'catalogue/js/carousel.js',
+            'catalogue/js/edumed.js',
+            'catalogue/js/lesson.js',
+            'catalogue/js/lesson-list.js',
+            'sponsors/js/sponsors.js',
+            'curriculum/curriculum.js',
+            'js/formset.js',
+            'pybb/js/pybbjs.js',
+            'fnpdjango/annoy/annoy.js',
+        ),
+        'output_filename': 'compressed/base.js',
+    },
+    'wtem': {
+        'source_filenames': (
+            'catalogue/js/jquery-ui-1.10.0.custom.js',
+            'wtem/edumed.js',
+            'wtem/wtem.js',
+            'wtem/json2.js'
+        ),
+        'output_filename': 'compressed/wtem.js'
+    },
+}
+
+PIPELINE_COMPILERS = (
+  'pipeline.compilers.sass.SASSCompiler',
+)
index 756ffa3..2dce875 100644 (file)
@@ -1,9 +1,10 @@
 # -*- coding: utf-8 -*-
 import codecs
 import csv
 # -*- coding: utf-8 -*-
 import codecs
 import csv
-
 import cStringIO
 
 import cStringIO
 
+from settings.apps import INSTALLED_APPS
+
 
 # source: https://docs.python.org/2/library/csv.html#examples
 class UnicodeCSVWriter(object):
 
 # source: https://docs.python.org/2/library/csv.html#examples
 class UnicodeCSVWriter(object):
@@ -33,4 +34,11 @@ class UnicodeCSVWriter(object):
 
     def writerows(self, rows):
         for row in rows:
 
     def writerows(self, rows):
         for row in rows:
-            self.writerow(row)
\ No newline at end of file
+            self.writerow(row)
+
+
+def process_app_deps(list_with_deps):
+    return tuple(
+        (x[0] if type(x) == tuple else x)
+        for x in list_with_deps
+        if type(x) != tuple or x[1] in INSTALLED_APPS)
\ No newline at end of file