"""
Django settings for eforms project.

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

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

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

import os
import raven
import djcelery
import paypalrestsdk
djcelery.setup_loader()

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
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.11/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'n=#y%z@%)t8ow3&hbic%9*&8_5l!0_ay_5nngxl0oz^p5%hjkz'
SITE_ID = 1
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ['*']

PAYMENT_OB = None
# Application definition

INSTALLED_APPS = [
    'jet',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
    'eforms_app',
    'djcelery',
    'rest_framework.authtoken',
    'corsheaders',
    'paypalrestsdk',
    'raven.contrib.django.raven_compat',
    'rest_framework_docs',
    'django_unused_media',

]

MIDDLEWARE = [

    'corsheaders.middleware.CorsMiddleware',
    'django.middleware.security.SecurityMiddleware',
    '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',
    'raven.contrib.django.raven_compat.middleware.Sentry404CatchMiddleware',
]

ROOT_URLCONF = 'eforms.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',
                'django.template.context_processors.media'
            ],
        },
    },
]

WSGI_APPLICATION = 'eforms.wsgi.application'



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

DATABASES = {
    'default1': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    },
      'default': {
         'ENGINE': 'django.db.backends.mysql',
         'NAME': 'eforms',
         'HOST': 'localhost',
         'PORT': '3306',
         'USER': 'root',
         'PASSWORD': 'root',
      }

}

AUTH_USER_MODEL = 'eforms_app.CustomUser'
CORS_ORIGIN_ALLOW_ALL = True

CORS_ALLOW_METHODS = (
    'DELETE',
    'GET',
    'OPTIONS',
    'PATCH',
    'POST',
    'PUT',
)
# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]


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

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = False

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES':
        (
            'rest_framework.authentication.TokenAuthentication',
        ),
    # 'DEFAULT_PERMISSION_CLASSES':
    #     (
    #         'rest_framework.permissions.IsAuthenticated',
    #     ),
}
AUTHENTICATION_BACKENDS = [
    'django.contrib.auth.backends.AllowAllUsersModelBackend',
    #'django.contrib.auth.backends.ModelBackend',
]

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

STATIC_URL = '/static/'

# MEDIA_ROOT = (os.path.join(BASE_DIR, 'media'))
MEDIA_ROOT = 'media/'
MEDIA_URL = '/media/'

EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'eforms2017@gmail.com'
EMAIL_HOST_PASSWORD = '#@make!secure1'
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
DEFAULT_FROM_EMAIL = 'ashutosh.tiwari@startxlabs.com'

BROKER_URL = 'redis://localhost:6379/0'
CELERY_RESULT_BACKEND = 'redis://localhost:6379/0'
CELERY_ACCEPT_CONTENT = ['json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'

ADMINS = ['ashutosh.tiwari@startxlabs.com']

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'verbose': {
            'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
        },
    },
    'handlers': {
        'sentry': {
            'level': 'WARNING',
            'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler',
        },
        'console': {
            'level': 'WARNING',
            'class': 'logging.StreamHandler',
            'formatter': 'verbose'
        },
        'file': {
            'level': 'DEBUG',
            'class': 'logging.FileHandler',
            'filename': os.path.join(BASE_DIR, 'celery.log'),
        }
    },
    'loggers': {
        'django': {
            'handlers': ['sentry'],
            'level': 'DEBUG',
            'propagate': True,
        },
        'raven': {
            'level': 'DEBUG',
            'handlers': ['sentry'],
            'propagate': False,
        },
        'sentry.errors': {
            'level': 'DEBUG',
            'handlers': ['sentry'],
            'propagate': False,
        },
        'eforms_app': {
            'level': 'DEBUG',
            'handlers': ['sentry'],
            'propagate': True
            ,
        },
    }
}

RAVEN_CONFIG = {
    'dsn': 'https://d16ab2857d824868b28d5f02ab82be16:a29517130ec3420cb2ca9a0a1fbd710d@sentry.io/168669',
}
DROPBOX_APP_KEY = 'u63iu2vaw9m7lvr'
DROPBOX_APP_SECRET = 'eivmmsbipnj3yx8'
GOOGLE_DRIVE_AUTH_URL = 'https://accounts.google.com/o/oauth2/auth'
GOOGLE_DRIVE_CLIENT_ID = '400267891048-qmk9qmi7h8ss1srib1jaj4fnp298bnhk.apps.googleusercontent.com'
GOOGLE_DRIVE_CLIENT_SECRET = 'NWG-w1RX_YSqUpyFV6JR-1p-'
GOOGLE_DRIVE_TOKEN_URL = 'https://accounts.google.com/o/oauth2/token'
# STATICFILES_DIRS = (
#    #This lets Django's collectstatic store our bundles
#    os.path.join(BASE_DIR, 'static'),
# )
STATIC_ROOT = os.path.join(BASE_DIR, "assets")

paypalrestsdk.configure({
                          'mode': 'sandbox', #sandbox or live
                          'client_id': 'AWB0KCOeBuKvOySDLOZ3Gdv_vc40C159_h95owgYPTHRK4HY8PDdeAl0RL3Ik91KfJhVguG9_baDgwug',
                          'client_secret': 'EFa9KJhcRrfHQzecylfJTeq6dMExB6kSpC1cPKXLGol6oUeUcjYpcdro3F8029jRFk7TZkYbirvXhOvZ'
                        }
)

JET_DEFAULT_THEME = 'light-violet'

JET_THEMES = [
    {
        'theme': 'default',
        'color': '#47bac1',
        'title': 'Default'
    },
    {
        'theme': 'green',
        'color': '#44b78b',
        'title': 'Green'
    },
    {
        'theme': 'light-green',
        'color': '#2faa60',
        'title': 'Light Green'
    },
    {
        'theme': 'light-violet',
        'color': '#a464c4',
        'title': 'Light Violet'
    },
    {
        'theme': 'light-blue',
        'color': '#5EADDE',
        'title': 'Light Blue'
    },
    {
        'theme': 'light-gray',
        'color': '#222',
        'title': 'Light Gray'
    }
]

JET_SIDE_MENU_COMPACT = True

JET_SIDE_MENU_ITEMS = [  # A list of application or custom item dicts
    {'label': ('FORMLIO'), 'app_label': 'eforms_app', 'items': [

        {'label': 'SiteUsers', 'url': 'https://formlioapi.webreview.xyz/admin/eforms_app/customuser/'},
        {'label': 'SignUpPromocode', 'url': 'https://formlioapi.webreview.xyz/admin/eforms_app/signuppromocode/'},
        {'label': 'AddUserPromoCode', 'url': 'https://formlioapi.webreview.xyz/admin/eforms_app/adduserpromocode/'},
        {'label': 'CustomerFormsPromoCode', 'url':
            'https://formlioapi.webreview.xyz/admin/eforms_app/customerformspromocode/'},
        {'label': 'DeclaredPaymentFee', 'url': 'https://formlioapi.webreview.xyz/admin/eforms_app/declaredpaymentfee/'},
        {'label': 'TrialPeriod', 'url': 'https://formlioapi.webreview.xyz/admin/eforms_app/trialperioddays/'}
    ]},
]

