"""
Django settings for gaialabsoftware project.

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

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__)))
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 = 'wz+91hav)pjpi6m&--@@bib2vkx&1je5(dk%a(!elvro$+^!ix'

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

ALLOWED_HOSTS = ['*']


# Application definition

INSTALLED_APPS = [
    'djangobower',
    'admin_tools',
    'admin_tools.theming',
    'admin_tools.menu',
    'admin_tools.dashboard',
    'django_crontab',
    'admin_tools_stats',
    'django_nvd3',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rest_framework',
    'patient_manager',
    'django_filters',
    'django.contrib.sites',
    'rest_framework.authtoken',
    'rest_auth',
    'dbbackup',  # django-dbbackup
    #"django_cron", #cron job handler

]



SITE_ID = 1

REST_FRAMEWORK = {

    'DEFAULT_FILTER_BACKENDS': (
        'django_filters.rest_framework.DjangoFilterBackend',
  
    ),
    # Use Django's standard `django.contrib.auth` permissions,
    # or allow read-only access for unauthenticated users.
    # 'DEFAULT_PARSER_CLASSES': (
    #     'rest_framework.parsers.JSONParser',
    # ),
    'DEFAULT_RENDERER_CLASSES' : (
        'rest_framework.renderers.JSONRenderer',
        'rest_framework.renderers.BrowsableAPIRenderer',
    ),

    'DEFAULT_AUTHENTICATION_CLASSES': (
        # 'rest_framework.authentication.BasicAuthentication',
        # 'rest_framework.authentication.SessionAuthentication',
        'rest_framework.authentication.TokenAuthentication',
    ),
    'DEFAULT_PERMISSION_CLASSES': [
        #'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly',
        #'rest_framework.permissions.DjangoModelPermissions'
        #'rest_framework.permissions.IsAuthenticatedOrReadOnly',
        #'rest_framework.permissions.IsAuthenticated'
        'rest_framework.permissions.AllowAny'

    ]
}


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

ROOT_URLCONF = 'gaialabsoftware.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS':  [os.path.join(BASE_DIR, 'templates'), 
                os.path.join(BASE_DIR, 'templates', 'admin'),
                #os.path.join(BASE_DIR, 'templates', 'error_templates'),
                #os.path.join(BASE_DIR, 'templates', 'pdf')
                # os.path.join(BASE_DIR, 'templates', 'account'),
                #os.path.join(BASE_DIR, 'templates', 'usuario'),
                #os.path.join(BASE_DIR, 'templates', 'forms'), # REGISTRATION FORMS TEMPLATES DIRECTORY
                #os.path.join(BASE_DIR, 'templates', 'usuario', 'condominios'), #CONDOMINIOS FINANCIAL TEMPLATES
                #os.path.join(BASE_DIR, 'templates', 'usuario', 'propietarios'), #CONDOMINIOS FINANCIAL TEMPLATES
                #os.path.join(BASE_DIR, 'templates', 'usuario', 'pdfTemplates'),
                #os.path.join(BASE_DIR, 'templates', 'admin', 'usuario'),
                #os.path.join(BASE_DIR, 'templates', 'markdown'),
                #os.path.join(BASE_DIR, 'templates', 'usuario', 'email')
                ],
        #'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.core.context_processors.request',
            ],
            'loaders':[
                'admin_tools.template_loaders.Loader',
                ('django.template.loaders.cached.Loader', [
                'django.template.loaders.filesystem.Loader',
                'django.template.loaders.app_directories.Loader',
                ]),
            ],
        },
    },
]

WSGI_APPLICATION = 'gaialabsoftware.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
# TEMPLATE_LOADERS = (
#     'django.template.loaders.filesystem.Loader',
#     'django.template.loaders.app_directories.Loader',
#     'admin_tools.template_loaders.Loader'
# )

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'gaiasoft',
        'USER': 'root',
        'PASSWORD': 'ou63ut14',
        'HOST': '127.0.0.1',
        'OPTIONS': {
            'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
        },
    }
}

# 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',
    },
]


#PROJECT EMAIL SETTINGS
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'peto813@gmail.com'
EMAIL_HOST_PASSWORD = 'ou63ut14#'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'peto813@gmail.com'
#EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
#EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
ADMINS = (('Einstein Millan', 'peto813@gmail.com'), ('Einstein Millan', 'peto813@hotmail.com'))


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

#LANGUAGE_CODE = 'en-us'

LANGUAGE_CODE = 'es-VE'

TIME_ZONE = 'America/Caracas'

USE_I18N = True

USE_L10N = True

USE_TZ = True


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

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

        #The absolute path to the directory where collectstatic will collect static files for deployment.
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, "static", "mystatic"), #this is where images, js and css go
)

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, "static", "media_root")
# these two have to do with end-users (whatever is being uploaded) 



#The maximum number of parameters that may be received via GET or POST before a SuspiciousOperation (TooManyFields) is raised
DATA_UPLOAD_MAX_NUMBER_FIELDS = None

#DJANGO BACKUP
DBBACKUP_STORAGE = 'storages.backends.dropbox.DropBoxStorage'
DBBACKUP_STORAGE_OPTIONS = {
    'oauth2_access_token': 'LnMjDYxN3XAAAAAAAAAACtCZAAOQoNMkcrOoWBDlKtDb-KFhbhVSsLsBuZBfQ4qs',
}

# DJANGO CRON-TAB

# CRON_CLASSES = [
#     "patient_manager.cron.BackupDatabaseDropBox",
#     # ...
# ]


#DJANGO CRON
CRONJOBS = [
    ('0 16 * * FRI', 'patient_manager.cron.BackupDatabaseDropBox')  #FRIDAY AT 4 PM
    #('* * * * *', 'patient_manager.cron.BackupDatabaseDropBox')  #EVERY MINUTE
]


# Specifie path to components root (you need to use absolute path)
#BOWER_COMPONENTS_ROOT = os.path.join(BASE_DIR, 'components')
#BOWER_PATH = '/usr/local/lib/node_modules/bower/bin/bower'

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    #'djangobower.finders.BowerFinder'
)


# BOWER_INSTALLED_APPS = (
#     'jquery#2.0.3',
#     'jquery-ui#~1.10.3',
#     'd3#3.3.6',
#     'nvd3#1.1.12-beta',
# )

ADMIN_TOOLS_MENU = 'patient_manager.custon_admin_menu.CustomMenu'
ADMIN_TOOLS_INDEX_DASHBOARD  = 'patient_manager.dashboard.CustomIndexDashboard'
ADMIN_TOOLS_APP_INDEX_DASHBOARD = 'patient_manager.dashboard.CustomAppIndexDashboard'
ADMIN_TOOLS_THEMING_CSS = 'css/django_admin_theming.css'
