"""
Django settings for mooc project.

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

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

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 = 'pxf234t25323vasfk3t202v2232v124'

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

ALLOWED_HOSTS = ['localhost', 'oer.hps.vi4io.org']

# Application definition

INSTALLED_APPS = (
#    'djangosecure',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # 3rd party
    #'rest_framework',
    'cookielaw',
    'social.apps.django_app.default',

    # project
    'main',
    'courses',
    'frontend',
    'rest',
    'generated_exercises', #TODO FIXME
    'tools'
)

MIDDLEWARE = (
#    'djangosecure.middleware.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.security.SecurityMiddleware',
)

#SECURE_SSL_REDIRECT = True
#SESSION_COOKIE_SECURE = True
#CSRF_COOKIE_SECURE = True

ROOT_URLCONF = 'main.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            os.path.join(BASE_DIR, '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',
                'social.apps.django_app.context_processors.backends',
                'social.apps.django_app.context_processors.login_redirect',
            ],
        },
    },
]

WSGI_APPLICATION = 'main.wsgi.application'



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

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

	# postgresql
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'hoou',
        'USER': 'hoou',
        'PASSWORD': 'hoohoohoo123',
        'HOST': 'localhost',
    }

}


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

LANGUAGE_CODE = 'en-us'

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 = '/data/run/static/'

# OAuth / OpenID Login Settings
###############################################################################

AUTHENTICATION_BACKENDS = (
    #'social.backends.open_id.OpenIdAuth',
    'social.backends.facebook.FacebookOAuth2',
    'social.backends.google.GoogleOAuth2',
    'social.backends.github.GithubOAuth2',
    'social.backends.twitter.TwitterOAuth',
    'social.backends.reddit.RedditOAuth2',
    'django.contrib.auth.backends.ModelBackend',
)

# GitHub
SOCIAL_AUTH_GITHUB_KEY = '4c726275a445b55d37ca'
SOCIAL_AUTH_GITHUB_SECRET = '84aec8b37a1b4b6b843d4161a4240f312a964fe1'

# Reddit
SOCIAL_AUTH_REDDIT_KEY = 'vAGMBJBPdnzLIw'
SOCIAL_AUTH_REDDIT_SECRET = 'riQyRWFrFZJKHLihG0_Y8cwO4cQ'
SOCIAL_AUTH_REDDIT_AUTH_EXTRA_ARGUMENTS = {'duration': 'permanent'}

# Twitter
SOCIAL_AUTH_TWITTER_KEY = 'kzONnzGZ1CKUATgSPx6BeMSjD'
SOCIAL_AUTH_TWITTER_SECRET = 'oIsRdyUafNgXIWQ7pjWisfgAFTOiKX9gBDWARc3wcwiO1Ay2dN'

# Google
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = '477896675547-pocqb7irgjttea34dc5efmtj8lqketaa.apps.googleusercontent.com'
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = 'TbdZdorX_YNyLJ9_y8ldBwuV'

# Facebook
SOCIAL_AUTH_FACEBOOK_KEY = '1651995468422055'
SOCIAL_AUTH_FACEBOOK_SECRET = '79b7652a72397e6f4b05e097d735e0e5'
SOCIAL_AUTH_FACEBOOK_SCOPE = ['email']





PIPELINE = (
  'social.pipeline.social_auth.social_details',
  'social.pipeline.social_auth.social_uid',
  'social.pipeline.social_auth.auth_allowed',
  'social.pipeline.social_auth.social_user',
  'social.pipeline.user.get_username',
  # 'social.pipeline.mail.mail_validation',
  'social.pipeline.social_auth.associate_by_email',
  'social.pipeline.user.create_user',
  'social.pipeline.social_auth.associate_user',
  'social.pipeline.social_auth.load_extra_data',
  'social.pipeline.user.user_details'
)


SOCIAL_AUTH_LOGIN_REDIRECT_URL = '/'
