"""
Django settings for FYP project.

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

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

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

import os

# 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.10/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '5(15ds+i2+%ik6z&!yer+ga9m=e%jcqiz_5wszg)r-z!2--b2di-projectx'

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

ALLOWED_HOSTS = ["*"]

# Application definition

INSTALLED_APPS = [
    'registration.apps.LoginConfig',
    'fbbot.apps.FbbotConfig',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
    'rest_framework',
#    'viewflow',
    'django_celery_results',
    'account',
#user admin, password: password123
    # do you have ngrok?yes copy https url
    #'fobi',

    # `django-fobi` themes
    #'fobi.contrib.themes.bootstrap3', # Bootstrap 3 theme
    #'fobi.contrib.themes.simple', # Bootstrap 3 theme


    # `django-fobi` form elements - fields
    #'fobi.contrib.plugins.form_elements.fields.boolean',
    #'fobi.contrib.plugins.form_elements.fields.email',
    #'fobi.contrib.plugins.form_elements.fields.integer',
    #'fobi.contrib.plugins.form_elements.fields.password',
    #'fobi.contrib.plugins.form_elements.fields.select',
    #'fobi.contrib.plugins.form_elements.fields.text',

    # `django-fobo` form handlers
    #'fobi.contrib.plugins.form_handlers.db_store',
    #'fobi.contrib.plugins.form_handlers.mail',

    #'forms.apps.Config'
]

REST_FRAMEWORK = {
    'DEFAULT_RENDERER_CLASSES': (
        'rest_framework.renderers.JSONRenderer',
    ),
    'DEFAULT_PARSER_CLASSES': (
        'rest_framework.parsers.JSONParser',
    ),
    'DEFAULT_PERMISSION_CLASSES': (
        'rest_framework.permissions.IsAdminUser',
    ),
    'PAGE_SIZE': 10
}

MIDDLEWARE = [
    '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',
    "account.middleware.LocaleMiddleware",
    "account.middleware.TimezoneMiddleware",
]

ROOT_URLCONF = 'FYP.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',
                "account.context_processors.account",
                #"pinax_theme_bootstrap.context_processors.theme",
            #"fobi.context_processors.theme",
            ],
        },
    },
]

WSGI_APPLICATION = 'FYP.wsgi.application'

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

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

# Password validation
# https://docs.djangoproject.com/en/1.10/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.10/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Facebook messenger bot

FB_APP_ID = '1046417492160406'
FB_PAGE_ID = '204027086778629'
FB_ACCESS_TOKEN = 'EAAO3tg7oL5YBAAVp0zQpD3UlFYUg2CE6t1GBOu0ZAZBkTCXWFQvp0myqT71t63zOcRgzQ5dcUO7itBSga7wwiGRArfg1YFf9GY6Gy1tQGWZBnpZBJ6RV0GWHBqtAZA5yaryDChKZATEqvrTxh90aPZCEgyAss1cxYYOwoLpRnfET8g6h4nuOcm4'
FB_APP_SECRET = 'b80401dc841ef794b7001a28ecff9d95'

CELERY_RESULT_BACKEND = 'django-db'

SITE_ID = 1

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

# FOBI forms configurations

#FOBI_THEME_FOOTER_TEXT = 'Project X All rights reserved!'
#INSTALLED_APPS.append('theme.apps.Config')
#PROJECT_NAME = 'Project X: Forms'
#FOBI_RESTRICT_PLUGIN_ACCESS = False


#Logging

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'handlers': {
        'file': {
            'level': 'DEBUG',
            'class': 'logging.FileHandler',
            'filename': 'E:\FYPfinal\debug.log', #update the file path point to your local dir
        },
    },
    'loggers': {
        'fbbot': {
            'handlers': ['file'],
            'level': 'DEBUG',
            'propagate': True,
        },
        'forms': {
            'handlers': ['file'],
            'level': 'DEBUG',
            'propagate': True,
        },
    },
}



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

STATIC_URL = '/static/'

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

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

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

MEDIA_URL = '/media/'

LOGIN_REDIRECT_URL = '/'

LOGOUT_REDIRECT_URL = 'login'

