"""
Django settings for dddppp 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/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
import pkg_resources
import pwd

PROJECT_NAME = 'dddppp'

# Enforce a valid POSIX environment
# Get missing environment variables via call to pwd.getpwuid(...)
_PW_CACHE = None
_PW_MAP = {
    'LOGNAME': 'pw_name',
    'USER': 'pw_name',
    'USERNAME': 'pw_name',
    'UID': 'pw_uid',
    'GID': 'pw_gid',
    'HOME': 'pw_dir',
    'SHELL': 'pw_shell',
}
for _missing_env in set(_PW_MAP).difference(os.environ):
    if _PW_CACHE is None:
        _PW_CACHE = pwd.getpwuid(os.getuid())
    os.environ[_missing_env] = str(getattr(_PW_CACHE, _PW_MAP[_missing_env]))
del _PW_CACHE, _PW_MAP, pwd

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__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 = 'nfd_lvt=&k#h#$a^_l09j#5%s=mg+0aw=@t84ry$&rps43c33+'

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

ALLOWED_HOSTS = [
    'localhost',
]


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'dddp',
    'dddp.server',
    'dddp.accounts',
    'dddppp.slides',
]

for (requirement, pth) in [
    ('django-extensions', 'django_extensions'),
]:
    try:
        pkg_resources.get_distribution(requirement)
    except (
        pkg_resources.DistributionNotFound,
        pkg_resources.VersionConflict,
    ):
        continue
    INSTALLED_APPS.append(pth)

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 = 'dddppp.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 = 'dddppp.wsgi.application'


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

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': os.environ.get('PGDATABASE', PROJECT_NAME),
        'USER': os.environ.get('PGUSER', os.environ['LOGNAME']),
        'PASSWORD': os.environ.get('DJANGO_DATABASE_PASSWORD', ''),
        'HOST': os.environ.get('PGHOST', ''),
        'PORT': os.environ.get('PGPORT', ''),
    }
}


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

LANGUAGE_CODE = 'en-au'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


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

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

STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'

# django-secure
# see: https://github.com/carljm/django-secure/ for more options
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
#SECURE_SSL_REDIRECT = True
SECURE_CONTENT_TYPE_NOSNIFF = True
SECURE_FRAME_DENY = True
SESSION_COOKIE_SECURE = True
SESSION_COOKIE_HTTPONLY = True

DDDPPP_CONTENT_TYPES = []
PROJ_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))

[((147, 14, 147, 46), 'os.path.join', 'os.path.join', ({(147, 27, 147, 35): 'BASE_DIR', (147, 37, 147, 45): '"""static"""'}, {}), "(BASE_DIR, 'static')", False, 'import os\n'), ((38, 43, 38, 68), 'os.path.abspath', 'os.path.abspath', ({(38, 59, 38, 67): '__file__'}, {}), '(__file__)', False, 'import os\n'), ((74, 8, 74, 51), 'pkg_resources.get_distribution', 'pkg_resources.get_distribution', ({(74, 39, 74, 50): 'requirement'}, {}), '(requirement)', False, 'import pkg_resources\n'), ((120, 16, 120, 58), 'os.environ.get', 'os.environ.get', ({(120, 31, 120, 43): '"""PGDATABASE"""', (120, 45, 120, 57): 'PROJECT_NAME'}, {}), "('PGDATABASE', PROJECT_NAME)", False, 'import os\n'), ((121, 16, 121, 63), 'os.environ.get', 'os.environ.get', ({(121, 31, 121, 39): '"""PGUSER"""', (121, 41, 121, 62): "os.environ['LOGNAME']"}, {}), "('PGUSER', os.environ['LOGNAME'])", False, 'import os\n'), ((122, 20, 122, 66), 'os.environ.get', 'os.environ.get', ({(122, 35, 122, 61): '"""DJANGO_DATABASE_PASSWORD"""', (122, 63, 122, 65): '""""""'}, {}), "('DJANGO_DATABASE_PASSWORD', '')", False, 'import os\n'), ((123, 16, 123, 44), 'os.environ.get', 'os.environ.get', ({(123, 31, 123, 39): '"""PGHOST"""', (123, 41, 123, 43): '""""""'}, {}), "('PGHOST', '')", False, 'import os\n'), ((124, 16, 124, 44), 'os.environ.get', 'os.environ.get', ({(124, 31, 124, 39): '"""PGPORT"""', (124, 41, 124, 43): '""""""'}, {}), "('PGPORT', '')", False, 'import os\n'), ((161, 41, 161, 66), 'os.path.dirname', 'os.path.dirname', ({(161, 57, 161, 65): '__file__'}, {}), '(__file__)', False, 'import os\n'), ((34, 33, 34, 44), 'os.getuid', 'os.getuid', ({}, {}), '()', False, 'import os\n')]