"""
Django settings for core project.

Generated by 'django-admin startproject' using Django 1.8.2.

For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""

import os


BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = 'MillisecondsMatter'
DEBUG = False

# Application definition
INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'algoliasearch_django',
    'tests'
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.security.SecurityMiddleware',
)

MIDDLEWARE = [
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
]

TEMPLATES = [
    {
        "BACKEND": "django.template.backends.django.DjangoTemplates",
        "DIRS": [],
        "APP_DIRS": True,
        "OPTIONS": {
            "context_processors": [
                "django.template.context_processors.debug",
                "django.template.context_processors.request",
                "django.contrib.auth.context_processors.auth",
                "django.contrib.messages.context_processors.messages",
            ],
        },
    },
]

ROOT_URLCONF = 'tests.urls'

# Database
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

# Internationalization
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True


def safe_index_name(name):
    if 'TRAVIS' not in os.environ:
        return name
    job = os.environ['TRAVIS_JOB_NUMBER']
    return '{}_travis-{}'.format(name, job)

# AlgoliaSearch settings
ALGOLIA = {
    'APPLICATION_ID': os.getenv('ALGOLIA_APPLICATION_ID'),
    'API_KEY': os.getenv('ALGOLIA_API_KEY'),
    'INDEX_PREFIX': 'test',
    'INDEX_SUFFIX': safe_index_name('django'),
    'RAISE_EXCEPTIONS': True
}

@@ -717,20 +717,72 @@
 WARE
-_CLASSES = (
+ = %5B%0A    'django.contrib.sessions.middleware.SessionMiddleware',
 %0A   
@@ -868,32 +868,95 @@
 iewMiddleware',%0A
+    'django.contrib.auth.middleware.AuthenticationMiddleware',%0A
     'django.cont
@@ -1001,32 +1001,92 @@
 ionMiddleware',%0A
+    'django.contrib.messages.middleware.MessageMiddleware',%0A
     'django.midd
@@ -1123,32 +1123,32 @@
 onsMiddleware',%0A
+
     'django.midd
@@ -1188,209 +1188,8 @@
 e',%0A
-)%0A%0AMIDDLEWARE = %5B%0A    'django.contrib.sessions.middleware.SessionMiddleware',%0A    'django.contrib.auth.middleware.AuthenticationMiddleware',%0A    'django.contrib.messages.middleware.MessageMiddleware',%0A
 %5D%0A%0AT

remove MIDDLEWARE_CLASSES