"""
Django settings for imagr_site project.

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

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

import os
from configurations import Configuration


class Base(Configuration):

    SECRET_KEY = os.environ.get('SECRET_KEY')
    BASE_DIR = os.path.dirname(os.path.dirname(__file__))
    LANGUAGE_CODE = 'en-us'
    TIME_ZONE = 'UTC'
    USE_I18N = True
    USE_L10N = True
    USE_TZ = True
    ALLOWED_HOSTS = []
    AUTH_USER_MODEL = 'imagr_users.ImagrUser'
    # Media Root Definition
    MEDIA_ROOT = os.path.join(BASE_DIR, "media")
    MEDIA_URL = "/media/"

    INSTALLED_APPS = (
        'sorl.thumbnail',
        'south',
        'imagr_users',
        'imagr_images',
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        )
    MIDDLEWARE_CLASSES = (
        'django.contrib.sessions.middleware.SessionMiddleware',
        'django.middleware.common.CommonMiddleware',
        'django.middleware.csrf.CsrfViewMiddleware',
        'django.contrib.auth.middleware.AuthenticationMiddleware',
        'django.contrib.messages.middleware.MessageMiddleware',
        'django.middleware.clickjacking.XFrameOptionsMiddleware',
    )

    ROOT_URLCONF = 'imagr_site.urls'

    WSGI_APPLICATION = 'imagr_site.wsgi.application'

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


class Dev(Base):

    DEBUG = True
    TEMPLATE_DEBUG = True
    THUMBNAIL_DEBUG = True

    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.postgresql_psycopg2',
            'NAME': 'imagrdb',
        }
    }

    CACHES = {
        'default': {
            'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
            'LOCATION': '127.0.0.1:11211',
        }
    }


class Testing(Dev):
    SECRET_KEY = "supersecretkey"


class Prod(Base):

    # these need to be finished
    BASE_DIR = os.path.dirname(os.path.dirname(__file__))

    STATIC_ROOT = '/var/www/static/'
    MEDIA_ROOT = '/var/www/media/'
    # set static url and media url
    STATIC_URL = '/static/'
    MEDIA_URL = '/media/'
    DEBUG = False
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.postgresql_psycopg2',
            'NAME': os.environ.get('PG_IMAGR_DB', ''),
            'USER': os.environ.get('PG_IMAGR_USERNAME', ''),
            'PASSWORD':  os.environ.get('PG_IMAGR_PASSWORD', ''),
            'HOST': os.environ.get('PG_IMAGR_HOSTNAME', ''),
            'PORT': '5432'
        }
    }
    # we need to get this working
    ALLOWED_HOSTS = [os.environ.get('CURRENT_HOST', '')]
