"""
Django settings for socialDistribution project on Heroku. Fore more info, see:
https://github.com/heroku/heroku-django-template

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
import dj_database_url

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(__file__))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'hdn#t@ayramjvr&cqps&n2x#*_u*82ykzl9-2j3ax-8=80-q_-'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

TEMPLATE_DEBUG = True


# Application definition

INSTALLED_APPS = (
    'django.contrib.admin.apps.SimpleAdminConfig',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rest_framework',
    'api',
    'post',
    'manager',
    'widget_tweaks',
    'markdown_deux',
)

MIDDLEWARE_CLASSES = (
    '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',
    'django.middleware.security.SecurityMiddleware',
)

ROOT_URLCONF = 'socialDistribution.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': ['templates'],
        '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 = 'socialDistribution.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases

os.environ['HEROKU_POSTGRESQL_ONYX_URL'] = 'postgres://uxhbeyawhjsjfn:kFc6PC4UtGR7vMKNKsY_HewSxy@ec2-54-225-151-64.compute-1.amazonaws.com:5432/d570u2qumrhm46'
DATABASES = {
    'default': dj_database_url.config(default=os.environ['HEROKU_POSTGRESQL_ONYX_URL'])
}



# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/

LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'America/Edmonton'
USE_I18N = True
USE_L10N = True
USE_TZ = True


# Parse database configuration from $DATABASE_URL
# DATABASES['default'] =  dj_database_url.config()

# Enable Connection Pooling (if desired)
# DATABASES['default']['ENGINE'] = 'django_postgrespool'

# Honor the 'X-Forwarded-Proto' header for request.is_secure()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

# Allow all host headers
ALLOWED_HOSTS = ['*']

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/

BASE_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = 'staticfiles'
STATIC_URL = '/static/'

#this page told me we need this for images: http://stackoverflow.com/questions/5871730/need-a-minimal-django-file-upload-example
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'

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

# Simplified static file serving.
# https://warehouse.python.org/project/whitenoise/
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'


LOGIN_REDIRECT_URL = '/'


REST_FRAMEWORK = {
    'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
    'PAGE_SIZE': 50,
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework.authentication.BasicAuthentication',
        'rest_framework.authentication.SessionAuthentication',
    )
}

@@ -2394,269 +2394,146 @@
 es%0A%0A
-os.environ%5B'HEROKU_POSTGRESQL_ONYX_URL'%5D = 'postgres://uxhbeyawhjsjfn:kFc6PC4UtGR7vMKNKsY_HewSxy@ec2-54-225-151-64.compute-1.amazonaws.com:5432/d570u2qumrhm46'%0ADATABASES = %7B%0A    'default': dj_database_url.config(default=os.environ%5B'HEROKU_POSTGRESQL_ONYX_URL'%5D)
+DATABASES = %7B%0A    'default': %7B%0A        'ENGINE': 'django.db.backends.sqlite3',%0A        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),%0A    %7D
 %0A%7D%0A%0A

switch back to sqllitedb