"""
Django settings for crossfire project.

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

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

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

import os
import sys
from configurations import Configuration, values

class Common(Configuration):
    BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    SECRET_KEY = values.SecretValue()
    DEBUG = values.BooleanValue(False)
    ALLOWED_HOSTS = []
    INSTALLED_APPS = [
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'whitenoise.runserver_nostatic',
        'django.contrib.staticfiles',
        'django_extensions',
        'waffle',
        'xpserver_api',
        'xpserver_web',
        'pipeline',
    ]

    MIDDLEWARE_CLASSES = [
        'django.middleware.security.SecurityMiddleware',
        'whitenoise.middleware.WhiteNoiseMiddleware',
        'django.contrib.sessions.middleware.SessionMiddleware',
        'django.middleware.common.CommonMiddleware',
        'django.middleware.csrf.CsrfViewMiddleware',
        'django.contrib.auth.middleware.AuthenticationMiddleware',
        'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
        'django.contrib.messages.middleware.MessageMiddleware',
        'django.middleware.clickjacking.XFrameOptionsMiddleware',
        'waffle.middleware.WaffleMiddleware'
    ]

    LOGGING = {
        "version": 1,
        "disable_existing_loggers": False,
        "handlers": {
            "console": {
                "level": "INFO",
                "class": "logging.StreamHandler",
                "stream": sys.stdout
            },
        },
        "loggers": {
            "django": {
                "handlers": ["console"],
            }
        }
    }

    ROOT_URLCONF = 'xpserver.urls'

    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',
                ],
            },
        },
    ]

    WSGI_APPLICATION = 'xpserver.wsgi.application'

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

    import dj_database_url
    db_from_env = dj_database_url.config(conn_max_age=500)
    DATABASES['default'].update(db_from_env)


    AUTH_PASSWORD_VALIDATORS = [
        {
            'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
        },
        {
            'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
        },
        {
            'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
        },
        {
            'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
        },
    ]

    LANGUAGE_CODE = 'en-us'

    TIME_ZONE = 'Europe/Belgrade'

    USE_I18N = True

    USE_L10N = True

    USE_TZ = True

    PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))

    STATIC_URL = '/static/'
    STATIC_ROOT = os.path.abspath(os.path.join(BASE_DIR, 'staticfiles'))

    STATICFILES_DIRS = (
        os.path.join(BASE_DIR, 'static'),
    )

    STATIC_FILEFINDERS = (
        'django.contrib.staticfiles.finders.FileSystemFinders',
        'django.contrib.staticfiles.finders.AppDirectoriesFinder',
        'pipeline.finders.PipelineFinder',
    )

    STATICFILE_STORAGE = 'xpserver.storage.WhiteNoisePipelineStorage'

    PIPELINE = {
        'PIPELINE_ENABLED': True,
        'STYLESHEETS': {
            'bootstrap': {
                'source_filenames': (
                    'assets/less/bootstrap.less',
                ),
                'output_filename': 'css/bootstrap.css',
            }
        },
        'COMPILERS': (
            'pipeline.compilers.less.LessCompiler',
        ),
    }



class Development(Common):
    DEBUG = True
    ALLOWED_HOSTS = []
    LOGGING = {
        "version": 1,
        "disable_existing_loggers": False,
        "handlers": {
            "console": {
                "level": "DEBUG",
                "class": "logging.StreamHandler",
                "stream": sys.stdout
            },
        },
        "loggers": {
            "django": {
                "handlers": ["console"],
            }
        }
    }

class Staging(Common):
    ALLOWED_HOSTS = ['cclz-xpserver.herokuapp.com']

class Production(Staging):
    ALLOWED_HOSTS = ['cclz-xpserver-prod.herokuapp.com']

@@ -4357,25 +4357,67 @@
   'C
-OMPILERS': (%0A    
+SS_COMPRESSOR': None,%0A    %7D%0A%0A    PIPELINE%5B'COMPILERS'%5D = (%0A
     
@@ -4468,20 +4468,9 @@
     
-    ),%0A    %7D
+)
 %0A%0A%0A%0A

Fix pipeline configuration