#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Django settings for MISHomeRun project.

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

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

from machina import get_apps as get_machina_apps
from machina import MACHINA_MAIN_TEMPLATE_DIR
from machina import MACHINA_MAIN_STATIC_DIR

from oscar import get_core_apps
from oscar import OSCAR_MAIN_TEMPLATE_DIR
from oscar.defaults import *
from django.utils.translation import ugettext_lazy as _

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

SITE_ID = 1

# 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 = '-8=w9hhf5s+k^dy@8crul*g%ko+#wd7o-2-w7)n477dyr#0a=j'

# SECURITY WARNING: don't run with debug turned on in production!
from Iuno import DEVELOPMENT, STAGE, PRODUCTION

SERVER_MODE = (DEVELOPMENT if 'SERVER_MODE' not in os.environ else
               locals()[(os.environ['SERVER_MODE'])])

DEBUG = True if SERVER_MODE not in (STAGE, PRODUCTION) else False

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
    'django.contrib.flatpages',

    'main',
    'customer2',
    'game',
    'team',
    'betting',

    'Iuno.member',

    'django_extensions',
    'mptt',
    'haystack',
    'widget_tweaks',
    'paypal',
    'ecpay',
    'compressor',
    'widget_tweaks',

    'ckeditor',
    'ckeditor_uploader',
] + get_machina_apps(['apps.forum_conversation']) + get_core_apps(['checkout',])

CKEDITOR_JQUERY_URL = '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js'
CKEDITOR_IMAGE_BACKEND = "pillow"

CKEDITOR_UPLOAD_PATH = "uploads/"

CKEDITOR_CONFIGS = {
    'default': {
        'toolbar': 'full',
        'height': 500,
        'width': 1000,
    },
}

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

    'machina.apps.forum_permission.middleware.ForumPermissionMiddleware',

    'oscar.apps.basket.middleware.BasketMiddleware',
    'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
)

ROOT_URLCONF = 'MISHomeRun.urls'

AUTH_USER_MODEL = 'main.User'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
                os.path.join(BASE_DIR, 'templates'),
                MACHINA_MAIN_TEMPLATE_DIR,
                OSCAR_MAIN_TEMPLATE_DIR,
            ],
        'APP_DIRS': False,
        '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',

                'machina.core.context_processors.metadata',

                'oscar.apps.search.context_processors.search_form',
                'oscar.apps.promotions.context_processors.promotions',
                'oscar.apps.checkout.context_processors.checkout',
                'oscar.apps.customer.notifications.context_processors.notifications',
                'oscar.core.context_processors.metadata',
            ],
            'loaders': [
                'django.template.loaders.filesystem.Loader',
                'django.template.loaders.app_directories.Loader',
            ]
        },
    },
]

WSGI_APPLICATION = 'MISHomeRun.wsgi.application'

# Haystack
HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
    },
}

HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
    },
}

AUTHENTICATION_BACKENDS = (
    'django.contrib.auth.backends.ModelBackend',
    'oscar.apps.customer.auth_backends.EmailBackend',
)

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

EMAIL_USE_TLS = True
EMAIL_HOST = 'mail.nuwainfo.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'test@nuwainfo.com'
EMAIL_HOST_PASSWORD = 'test25025529'
DEFAULT_FROM_EMAIL = 'test@nuwainfo.com'

OSCAR_FROM_EMAIL = DEFAULT_FROM_EMAIL

# http://www.xe.com/symbols.php
OSCAR_DEFAULT_CURRENCY = 'TWD'

OSCAR_HOMEPAGE = '/shop/catalogue/category/jin-bi_1/'

# PayPal Config


if SERVER_MODE == DEVELOPMENT:
    PAYPAL_SANDBOX_MODE = True
    
    PAYPAL_API_USERNAME = 'lavender15963j-facilitator_api1.gmail.com'
    PAYPAL_API_PASSWORD = 'QCC98A96EEYAVDNW'
    PAYPAL_API_SIGNATURE = 'AFcWxV21C7fd0v3bYYYRCpSSRl31AxFCpDXkIQYcNt0ChAH0ixFH98NB'
else:
    PAYPAL_SANDBOX_MODE = False

    PAYPAL_API_USERNAME = 'lavender15963j_api3.gmail.com'
    PAYPAL_API_PASSWORD = '9UJS47NY997ZAGSD'
    PAYPAL_API_SIGNATURE = 'AiPC9BjkCyDFQXbSkoZcgqH3hpacAK0h.O7u.6XDJVEojRRu7qvDICTz'
    
# ECPay
if SERVER_MODE == DEVELOPMENT or SERVER_MODE == STAGE:
    ECPAY_SANDBOX = True
    MERCHANT_ID = '2000132'
    HASH_KEY = '5294y06JbISpM5x9'
    HASH_IV = 'v77hoKGq4kWxNNIS'
else:
    ECPAY_SANDBOX = True
    MERCHANT_ID = '2000132'
    HASH_KEY = '5294y06JbISpM5x9'
    HASH_IV = 'v77hoKGq4kWxNNIS'
    
ALLPAY_AUTO_SEND_FORM = False

# http://localhost:8000/ 會被 view 取代掉    
RETURN_URL = 'http://localhost:8000/ecpay/preview/'
CLIENT_BACK_URL = 'http://localhost:8000/'
PAYMENT_INFO_URL = 'http://localhost:8000/feedback'
    
OSCAR_DASHBOARD_NAVIGATION += [
    {
        'label': _('PayPal'),
        'icon': 'icon-globe',
        'children':[
            {
                'label': _('Express transactions'),
                'url_name': 'paypal-express-list',
            },
        ]
    },
    ]



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


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

LANGUAGE_CODE = 'zh-hant'

TIME_ZONE = 'Asia/Taipei'

USE_I18N = True

USE_L10N = True

USE_TZ = True


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

location = lambda x: os.path.join(
    os.path.dirname(os.path.realpath(__file__)), x)
    
if DEBUG:
    STATIC_ROOT = location('static')
    
STATICFILES_FINDERS = [
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'compressor.finders.CompressorFinder',
]

#=========================================================================
# Iuno 
#=========================================================================
APP_NAME = 'MISHomeRun'
APP_VERSION = "1.0.0.0" # "$Revision: 133 $"[11:-2]

ALLOWED_HOSTS = ['127.0.0.1', 'localhost', '.mishomerun.com']

USE_X_FORWARDED_HOST = True

IUNO_MEMBER_ENABLE = True

import Iuno
Iuno.attachSettings(locals())

# Iuno.member

ACCOUNT_EMAIL_CONFIRMATION_REQUIRED = False


# Always use localhost static, not static.nuwainfo.com.
STATIC_URL = '/static/' 

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

CACHES = {
  'default': {
    'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
  },
  'machina_attachments': {
    'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
    'LOCATION': '/tmp',
  }
}

HAYSTACK_CONNECTIONS = {
  'default': {
    'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
  },
}

HAYSTACK_CONNECTIONS = {
  'default': {
    'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
    'PATH': os.path.join(BASE_DIR, 'whoosh_index'),
  },
}

MACHINA_DEFAULT_AUTHENTICATED_USER_FORUM_PERMISSIONS = [
    'can_see_forum',
    'can_read_forum',
    'can_start_new_topics',
    'can_reply_to_topics',
    'can_edit_own_posts',
    'can_post_without_approval',
    'can_create_polls',
    'can_vote_in_polls',
    'can_download_file',
]

MIGRATION_MODULES = {
  'forum_conversation': 'machina.apps.forum_conversation.migrations',
}

7988ad1aeeeb9918e7f3b4aa099bac2b5f565cdc
<mask token>

<mask token>
if SERVER_MODE == DEVELOPMENT:
    PAYPAL_SANDBOX_MODE = True
    PAYPAL_API_USERNAME = 'lavender15963j-facilitator_api1.gmail.com'
    PAYPAL_API_PASSWORD = 'QCC98A96EEYAVDNW'
    PAYPAL_API_SIGNATURE = (
        'AFcWxV21C7fd0v3bYYYRCpSSRl31AxFCpDXkIQYcNt0ChAH0ixFH98NB')
else:
    PAYPAL_SANDBOX_MODE = False
    PAYPAL_API_USERNAME = 'lavender15963j_api3.gmail.com'
    PAYPAL_API_PASSWORD = '9UJS47NY997ZAGSD'
    PAYPAL_API_SIGNATURE = (
        'AiPC9BjkCyDFQXbSkoZcgqH3hpacAK0h.O7u.6XDJVEojRRu7qvDICTz')
if SERVER_MODE == DEVELOPMENT or SERVER_MODE == STAGE:
    ECPAY_SANDBOX = True
    MERCHANT_ID = '2000132'
    HASH_KEY = '5294y06JbISpM5x9'
    HASH_IV = 'v77hoKGq4kWxNNIS'
else:
    ECPAY_SANDBOX = True
    MERCHANT_ID = '2000132'
    HASH_KEY = '5294y06JbISpM5x9'
    HASH_IV = 'v77hoKGq4kWxNNIS'
<mask token>
OSCAR_DASHBOARD_NAVIGATION += [{'label': _('PayPal'), 'icon': 'icon-globe',
    'children': [{'label': _('Express transactions'), 'url_name':
    'paypal-express-list'}]}]
<mask token>
if DEBUG:
    STATIC_ROOT = location('static')
<mask token>
Iuno.attachSettings(locals())
<mask token>

<mask token>
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SITE_ID = 1
SECRET_KEY = '-8=w9hhf5s+k^dy@8crul*g%ko+#wd7o-2-w7)n477dyr#0a=j'
<mask token>
SERVER_MODE = DEVELOPMENT if 'SERVER_MODE' not in os.environ else locals()[os
    .environ['SERVER_MODE']]
DEBUG = True if SERVER_MODE not in (STAGE, PRODUCTION) else False
ALLOWED_HOSTS = []
INSTALLED_APPS = ['django.contrib.admin', 'django.contrib.auth',
    'django.contrib.contenttypes', 'django.contrib.sessions',
    'django.contrib.messages', 'django.contrib.staticfiles',
    'django.contrib.sites', 'django.contrib.flatpages', 'main', 'customer2',
    'game', 'team', 'betting', 'Iuno.member', 'django_extensions', 'mptt',
    'haystack', 'widget_tweaks', 'paypal', 'ecpay', 'compressor',
    'widget_tweaks', 'ckeditor', 'ckeditor_uploader'] + get_machina_apps([
    'apps.forum_conversation']) + get_core_apps(['checkout'])
CKEDITOR_JQUERY_URL = (
    '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js')
CKEDITOR_IMAGE_BACKEND = 'pillow'
CKEDITOR_UPLOAD_PATH = 'uploads/'
CKEDITOR_CONFIGS = {'default': {'toolbar': 'full', 'height': 500, 'width': 
    1000}}
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',
    'machina.apps.forum_permission.middleware.ForumPermissionMiddleware',
    'oscar.apps.basket.middleware.BasketMiddleware',
    'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware')
ROOT_URLCONF = 'MISHomeRun.urls'
AUTH_USER_MODEL = 'main.User'
TEMPLATES = [{'BACKEND': 'django.template.backends.django.DjangoTemplates',
    'DIRS': [os.path.join(BASE_DIR, 'templates'), MACHINA_MAIN_TEMPLATE_DIR,
    OSCAR_MAIN_TEMPLATE_DIR], 'APP_DIRS': False, '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',
    'machina.core.context_processors.metadata',
    'oscar.apps.search.context_processors.search_form',
    'oscar.apps.promotions.context_processors.promotions',
    'oscar.apps.checkout.context_processors.checkout',
    'oscar.apps.customer.notifications.context_processors.notifications',
    'oscar.core.context_processors.metadata'], 'loaders': [
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader']}}]
WSGI_APPLICATION = 'MISHomeRun.wsgi.application'
HAYSTACK_CONNECTIONS = {'default': {'ENGINE':
    'haystack.backends.simple_backend.SimpleEngine'}}
HAYSTACK_CONNECTIONS = {'default': {'ENGINE':
    'haystack.backends.simple_backend.SimpleEngine'}}
AUTHENTICATION_BACKENDS = ('django.contrib.auth.backends.ModelBackend',
    'oscar.apps.customer.auth_backends.EmailBackend')
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_HOST = 'mail.nuwainfo.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'test@nuwainfo.com'
EMAIL_HOST_PASSWORD = 'test25025529'
DEFAULT_FROM_EMAIL = 'test@nuwainfo.com'
OSCAR_FROM_EMAIL = DEFAULT_FROM_EMAIL
OSCAR_DEFAULT_CURRENCY = 'TWD'
OSCAR_HOMEPAGE = '/shop/catalogue/category/jin-bi_1/'
if SERVER_MODE == DEVELOPMENT:
    PAYPAL_SANDBOX_MODE = True
    PAYPAL_API_USERNAME = 'lavender15963j-facilitator_api1.gmail.com'
    PAYPAL_API_PASSWORD = 'QCC98A96EEYAVDNW'
    PAYPAL_API_SIGNATURE = (
        'AFcWxV21C7fd0v3bYYYRCpSSRl31AxFCpDXkIQYcNt0ChAH0ixFH98NB')
else:
    PAYPAL_SANDBOX_MODE = False
    PAYPAL_API_USERNAME = 'lavender15963j_api3.gmail.com'
    PAYPAL_API_PASSWORD = '9UJS47NY997ZAGSD'
    PAYPAL_API_SIGNATURE = (
        'AiPC9BjkCyDFQXbSkoZcgqH3hpacAK0h.O7u.6XDJVEojRRu7qvDICTz')
if SERVER_MODE == DEVELOPMENT or SERVER_MODE == STAGE:
    ECPAY_SANDBOX = True
    MERCHANT_ID = '2000132'
    HASH_KEY = '5294y06JbISpM5x9'
    HASH_IV = 'v77hoKGq4kWxNNIS'
else:
    ECPAY_SANDBOX = True
    MERCHANT_ID = '2000132'
    HASH_KEY = '5294y06JbISpM5x9'
    HASH_IV = 'v77hoKGq4kWxNNIS'
ALLPAY_AUTO_SEND_FORM = False
RETURN_URL = 'http://localhost:8000/ecpay/preview/'
CLIENT_BACK_URL = 'http://localhost:8000/'
PAYMENT_INFO_URL = 'http://localhost:8000/feedback'
OSCAR_DASHBOARD_NAVIGATION += [{'label': _('PayPal'), 'icon': 'icon-globe',
    'children': [{'label': _('Express transactions'), 'url_name':
    'paypal-express-list'}]}]
LANGUAGE_CODE = 'zh-hant'
TIME_ZONE = 'Asia/Taipei'
USE_I18N = True
USE_L10N = True
USE_TZ = True
location = lambda x: os.path.join(os.path.dirname(os.path.realpath(__file__
    )), x)
if DEBUG:
    STATIC_ROOT = location('static')
STATICFILES_FINDERS = ['django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'compressor.finders.CompressorFinder']
APP_NAME = 'MISHomeRun'
APP_VERSION = '1.0.0.0'
ALLOWED_HOSTS = ['127.0.0.1', 'localhost', '.mishomerun.com']
USE_X_FORWARDED_HOST = True
IUNO_MEMBER_ENABLE = True
<mask token>
Iuno.attachSettings(locals())
ACCOUNT_EMAIL_CONFIRMATION_REQUIRED = False
STATIC_URL = '/static/'
STATICFILES_DIRS = os.path.join(BASE_DIR, 'static'), MACHINA_MAIN_STATIC_DIR
CACHES = {'default': {'BACKEND':
    'django.core.cache.backends.locmem.LocMemCache'}, 'machina_attachments':
    {'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
    'LOCATION': '/tmp'}}
HAYSTACK_CONNECTIONS = {'default': {'ENGINE':
    'haystack.backends.simple_backend.SimpleEngine'}}
HAYSTACK_CONNECTIONS = {'default': {'ENGINE':
    'haystack.backends.whoosh_backend.WhooshEngine', 'PATH': os.path.join(
    BASE_DIR, 'whoosh_index')}}
MACHINA_DEFAULT_AUTHENTICATED_USER_FORUM_PERMISSIONS = ['can_see_forum',
    'can_read_forum', 'can_start_new_topics', 'can_reply_to_topics',
    'can_edit_own_posts', 'can_post_without_approval', 'can_create_polls',
    'can_vote_in_polls', 'can_download_file']
MIGRATION_MODULES = {'forum_conversation':
    'machina.apps.forum_conversation.migrations'}

<mask token>
import os
from machina import get_apps as get_machina_apps
from machina import MACHINA_MAIN_TEMPLATE_DIR
from machina import MACHINA_MAIN_STATIC_DIR
from oscar import get_core_apps
from oscar import OSCAR_MAIN_TEMPLATE_DIR
from oscar.defaults import *
from django.utils.translation import ugettext_lazy as _
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SITE_ID = 1
SECRET_KEY = '-8=w9hhf5s+k^dy@8crul*g%ko+#wd7o-2-w7)n477dyr#0a=j'
from Iuno import DEVELOPMENT, STAGE, PRODUCTION
SERVER_MODE = DEVELOPMENT if 'SERVER_MODE' not in os.environ else locals()[os
    .environ['SERVER_MODE']]
DEBUG = True if SERVER_MODE not in (STAGE, PRODUCTION) else False
ALLOWED_HOSTS = []
INSTALLED_APPS = ['django.contrib.admin', 'django.contrib.auth',
    'django.contrib.contenttypes', 'django.contrib.sessions',
    'django.contrib.messages', 'django.contrib.staticfiles',
    'django.contrib.sites', 'django.contrib.flatpages', 'main', 'customer2',
    'game', 'team', 'betting', 'Iuno.member', 'django_extensions', 'mptt',
    'haystack', 'widget_tweaks', 'paypal', 'ecpay', 'compressor',
    'widget_tweaks', 'ckeditor', 'ckeditor_uploader'] + get_machina_apps([
    'apps.forum_conversation']) + get_core_apps(['checkout'])
CKEDITOR_JQUERY_URL = (
    '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js')
CKEDITOR_IMAGE_BACKEND = 'pillow'
CKEDITOR_UPLOAD_PATH = 'uploads/'
CKEDITOR_CONFIGS = {'default': {'toolbar': 'full', 'height': 500, 'width': 
    1000}}
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',
    'machina.apps.forum_permission.middleware.ForumPermissionMiddleware',
    'oscar.apps.basket.middleware.BasketMiddleware',
    'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware')
ROOT_URLCONF = 'MISHomeRun.urls'
AUTH_USER_MODEL = 'main.User'
TEMPLATES = [{'BACKEND': 'django.template.backends.django.DjangoTemplates',
    'DIRS': [os.path.join(BASE_DIR, 'templates'), MACHINA_MAIN_TEMPLATE_DIR,
    OSCAR_MAIN_TEMPLATE_DIR], 'APP_DIRS': False, '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',
    'machina.core.context_processors.metadata',
    'oscar.apps.search.context_processors.search_form',
    'oscar.apps.promotions.context_processors.promotions',
    'oscar.apps.checkout.context_processors.checkout',
    'oscar.apps.customer.notifications.context_processors.notifications',
    'oscar.core.context_processors.metadata'], 'loaders': [
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader']}}]
WSGI_APPLICATION = 'MISHomeRun.wsgi.application'
HAYSTACK_CONNECTIONS = {'default': {'ENGINE':
    'haystack.backends.simple_backend.SimpleEngine'}}
HAYSTACK_CONNECTIONS = {'default': {'ENGINE':
    'haystack.backends.simple_backend.SimpleEngine'}}
AUTHENTICATION_BACKENDS = ('django.contrib.auth.backends.ModelBackend',
    'oscar.apps.customer.auth_backends.EmailBackend')
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_HOST = 'mail.nuwainfo.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'test@nuwainfo.com'
EMAIL_HOST_PASSWORD = 'test25025529'
DEFAULT_FROM_EMAIL = 'test@nuwainfo.com'
OSCAR_FROM_EMAIL = DEFAULT_FROM_EMAIL
OSCAR_DEFAULT_CURRENCY = 'TWD'
OSCAR_HOMEPAGE = '/shop/catalogue/category/jin-bi_1/'
if SERVER_MODE == DEVELOPMENT:
    PAYPAL_SANDBOX_MODE = True
    PAYPAL_API_USERNAME = 'lavender15963j-facilitator_api1.gmail.com'
    PAYPAL_API_PASSWORD = 'QCC98A96EEYAVDNW'
    PAYPAL_API_SIGNATURE = (
        'AFcWxV21C7fd0v3bYYYRCpSSRl31AxFCpDXkIQYcNt0ChAH0ixFH98NB')
else:
    PAYPAL_SANDBOX_MODE = False
    PAYPAL_API_USERNAME = 'lavender15963j_api3.gmail.com'
    PAYPAL_API_PASSWORD = '9UJS47NY997ZAGSD'
    PAYPAL_API_SIGNATURE = (
        'AiPC9BjkCyDFQXbSkoZcgqH3hpacAK0h.O7u.6XDJVEojRRu7qvDICTz')
if SERVER_MODE == DEVELOPMENT or SERVER_MODE == STAGE:
    ECPAY_SANDBOX = True
    MERCHANT_ID = '2000132'
    HASH_KEY = '5294y06JbISpM5x9'
    HASH_IV = 'v77hoKGq4kWxNNIS'
else:
    ECPAY_SANDBOX = True
    MERCHANT_ID = '2000132'
    HASH_KEY = '5294y06JbISpM5x9'
    HASH_IV = 'v77hoKGq4kWxNNIS'
ALLPAY_AUTO_SEND_FORM = False
RETURN_URL = 'http://localhost:8000/ecpay/preview/'
CLIENT_BACK_URL = 'http://localhost:8000/'
PAYMENT_INFO_URL = 'http://localhost:8000/feedback'
OSCAR_DASHBOARD_NAVIGATION += [{'label': _('PayPal'), 'icon': 'icon-globe',
    'children': [{'label': _('Express transactions'), 'url_name':
    'paypal-express-list'}]}]
LANGUAGE_CODE = 'zh-hant'
TIME_ZONE = 'Asia/Taipei'
USE_I18N = True
USE_L10N = True
USE_TZ = True
location = lambda x: os.path.join(os.path.dirname(os.path.realpath(__file__
    )), x)
if DEBUG:
    STATIC_ROOT = location('static')
STATICFILES_FINDERS = ['django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'compressor.finders.CompressorFinder']
APP_NAME = 'MISHomeRun'
APP_VERSION = '1.0.0.0'
ALLOWED_HOSTS = ['127.0.0.1', 'localhost', '.mishomerun.com']
USE_X_FORWARDED_HOST = True
IUNO_MEMBER_ENABLE = True
import Iuno
Iuno.attachSettings(locals())
ACCOUNT_EMAIL_CONFIRMATION_REQUIRED = False
STATIC_URL = '/static/'
STATICFILES_DIRS = os.path.join(BASE_DIR, 'static'), MACHINA_MAIN_STATIC_DIR
CACHES = {'default': {'BACKEND':
    'django.core.cache.backends.locmem.LocMemCache'}, 'machina_attachments':
    {'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
    'LOCATION': '/tmp'}}
HAYSTACK_CONNECTIONS = {'default': {'ENGINE':
    'haystack.backends.simple_backend.SimpleEngine'}}
HAYSTACK_CONNECTIONS = {'default': {'ENGINE':
    'haystack.backends.whoosh_backend.WhooshEngine', 'PATH': os.path.join(
    BASE_DIR, 'whoosh_index')}}
MACHINA_DEFAULT_AUTHENTICATED_USER_FORUM_PERMISSIONS = ['can_see_forum',
    'can_read_forum', 'can_start_new_topics', 'can_reply_to_topics',
    'can_edit_own_posts', 'can_post_without_approval', 'can_create_polls',
    'can_vote_in_polls', 'can_download_file']
MIGRATION_MODULES = {'forum_conversation':
    'machina.apps.forum_conversation.migrations'}

#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Django settings for MISHomeRun project.

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

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

from machina import get_apps as get_machina_apps
from machina import MACHINA_MAIN_TEMPLATE_DIR
from machina import MACHINA_MAIN_STATIC_DIR

from oscar import get_core_apps
from oscar import OSCAR_MAIN_TEMPLATE_DIR
from oscar.defaults import *
from django.utils.translation import ugettext_lazy as _

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

SITE_ID = 1

# 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 = '-8=w9hhf5s+k^dy@8crul*g%ko+#wd7o-2-w7)n477dyr#0a=j'

# SECURITY WARNING: don't run with debug turned on in production!
from Iuno import DEVELOPMENT, STAGE, PRODUCTION

SERVER_MODE = (DEVELOPMENT if 'SERVER_MODE' not in os.environ else
               locals()[(os.environ['SERVER_MODE'])])

DEBUG = True if SERVER_MODE not in (STAGE, PRODUCTION) else False

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
    'django.contrib.flatpages',

    'main',
    'customer2',
    'game',
    'team',
    'betting',

    'Iuno.member',

    'django_extensions',
    'mptt',
    'haystack',
    'widget_tweaks',
    'paypal',
    'ecpay',
    'compressor',
    'widget_tweaks',

    'ckeditor',
    'ckeditor_uploader',
] + get_machina_apps(['apps.forum_conversation']) + get_core_apps(['checkout',])

CKEDITOR_JQUERY_URL = '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js'
CKEDITOR_IMAGE_BACKEND = "pillow"

CKEDITOR_UPLOAD_PATH = "uploads/"

CKEDITOR_CONFIGS = {
    'default': {
        'toolbar': 'full',
        'height': 500,
        'width': 1000,
    },
}

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

    'machina.apps.forum_permission.middleware.ForumPermissionMiddleware',

    'oscar.apps.basket.middleware.BasketMiddleware',
    'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
)

ROOT_URLCONF = 'MISHomeRun.urls'

AUTH_USER_MODEL = 'main.User'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
                os.path.join(BASE_DIR, 'templates'),
                MACHINA_MAIN_TEMPLATE_DIR,
                OSCAR_MAIN_TEMPLATE_DIR,
            ],
        'APP_DIRS': False,
        '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',

                'machina.core.context_processors.metadata',

                'oscar.apps.search.context_processors.search_form',
                'oscar.apps.promotions.context_processors.promotions',
                'oscar.apps.checkout.context_processors.checkout',
                'oscar.apps.customer.notifications.context_processors.notifications',
                'oscar.core.context_processors.metadata',
            ],
            'loaders': [
                'django.template.loaders.filesystem.Loader',
                'django.template.loaders.app_directories.Loader',
            ]
        },
    },
]

WSGI_APPLICATION = 'MISHomeRun.wsgi.application'

# Haystack
HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
    },
}

HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
    },
}

AUTHENTICATION_BACKENDS = (
    'django.contrib.auth.backends.ModelBackend',
    'oscar.apps.customer.auth_backends.EmailBackend',
)

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

EMAIL_USE_TLS = True
EMAIL_HOST = 'mail.nuwainfo.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'test@nuwainfo.com'
EMAIL_HOST_PASSWORD = 'test25025529'
DEFAULT_FROM_EMAIL = 'test@nuwainfo.com'

OSCAR_FROM_EMAIL = DEFAULT_FROM_EMAIL

# http://www.xe.com/symbols.php
OSCAR_DEFAULT_CURRENCY = 'TWD'

OSCAR_HOMEPAGE = '/shop/catalogue/category/jin-bi_1/'

# PayPal Config


if SERVER_MODE == DEVELOPMENT:
    PAYPAL_SANDBOX_MODE = True
    
    PAYPAL_API_USERNAME = 'lavender15963j-facilitator_api1.gmail.com'
    PAYPAL_API_PASSWORD = 'QCC98A96EEYAVDNW'
    PAYPAL_API_SIGNATURE = 'AFcWxV21C7fd0v3bYYYRCpSSRl31AxFCpDXkIQYcNt0ChAH0ixFH98NB'
else:
    PAYPAL_SANDBOX_MODE = False

    PAYPAL_API_USERNAME = 'lavender15963j_api3.gmail.com'
    PAYPAL_API_PASSWORD = '9UJS47NY997ZAGSD'
    PAYPAL_API_SIGNATURE = 'AiPC9BjkCyDFQXbSkoZcgqH3hpacAK0h.O7u.6XDJVEojRRu7qvDICTz'
    
# ECPay
if SERVER_MODE == DEVELOPMENT or SERVER_MODE == STAGE:
    ECPAY_SANDBOX = True
    MERCHANT_ID = '2000132'
    HASH_KEY = '5294y06JbISpM5x9'
    HASH_IV = 'v77hoKGq4kWxNNIS'
else:
    ECPAY_SANDBOX = True
    MERCHANT_ID = '2000132'
    HASH_KEY = '5294y06JbISpM5x9'
    HASH_IV = 'v77hoKGq4kWxNNIS'
    
ALLPAY_AUTO_SEND_FORM = False

# http://localhost:8000/ 會被 view 取代掉    
RETURN_URL = 'http://localhost:8000/ecpay/preview/'
CLIENT_BACK_URL = 'http://localhost:8000/'
PAYMENT_INFO_URL = 'http://localhost:8000/feedback'
    
OSCAR_DASHBOARD_NAVIGATION += [
    {
        'label': _('PayPal'),
        'icon': 'icon-globe',
        'children':[
            {
                'label': _('Express transactions'),
                'url_name': 'paypal-express-list',
            },
        ]
    },
    ]



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


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

LANGUAGE_CODE = 'zh-hant'

TIME_ZONE = 'Asia/Taipei'

USE_I18N = True

USE_L10N = True

USE_TZ = True


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

location = lambda x: os.path.join(
    os.path.dirname(os.path.realpath(__file__)), x)
    
if DEBUG:
    STATIC_ROOT = location('static')
    
STATICFILES_FINDERS = [
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'compressor.finders.CompressorFinder',
]

#=========================================================================
# Iuno 
#=========================================================================
APP_NAME = 'MISHomeRun'
APP_VERSION = "1.0.0.0" # "$Revision: 133 $"[11:-2]

ALLOWED_HOSTS = ['127.0.0.1', 'localhost', '.mishomerun.com']

USE_X_FORWARDED_HOST = True

IUNO_MEMBER_ENABLE = True

import Iuno
Iuno.attachSettings(locals())

# Iuno.member

ACCOUNT_EMAIL_CONFIRMATION_REQUIRED = False


# Always use localhost static, not static.nuwainfo.com.
STATIC_URL = '/static/' 

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

CACHES = {
  'default': {
    'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
  },
  'machina_attachments': {
    'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
    'LOCATION': '/tmp',
  }
}

HAYSTACK_CONNECTIONS = {
  'default': {
    'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
  },
}

HAYSTACK_CONNECTIONS = {
  'default': {
    'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
    'PATH': os.path.join(BASE_DIR, 'whoosh_index'),
  },
}

MACHINA_DEFAULT_AUTHENTICATED_USER_FORUM_PERMISSIONS = [
    'can_see_forum',
    'can_read_forum',
    'can_start_new_topics',
    'can_reply_to_topics',
    'can_edit_own_posts',
    'can_post_without_approval',
    'can_create_polls',
    'can_vote_in_polls',
    'can_download_file',
]

MIGRATION_MODULES = {
  'forum_conversation': 'machina.apps.forum_conversation.migrations',
}
