"""
Django settings for NewsUp project.

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

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 = 'bf^&3($cknf*_8yoibzj=&!!+*(04ofnb=ur_#guz*018)10-l'

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

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'newsApp',
    'django_crontab',
)

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

ROOT_URLCONF = 'newsApp.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',
            ],
        },
    },
]

WSGI_APPLICATION = 'NewsUp.wsgi.application'


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

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'news_schema',                      # Or path to database file if using sqlite3.
        'USER': 'root',                      # Not used with sqlite3.
        'PASSWORD': '',                  # Not used with sqlite3.
        'HOST': '127.0.0.1',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '3306',                      # Set to empty string for default. Not used with sqlite3.
    }
}


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

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'Asia/Kolkata'

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

TEMPLATE_DIRS = (
    os.path.join(BASE_DIR,  'templates'),
)

LOGGING = {
    'version': 1,
    'disable_existing_loggers': True,
    'formatters': {
        'verbose': {
            'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
        },
        'simple': {
            'format': '%(levelname)s %(message)s'
        },
    },
    'handlers': {
        'null': {
            'level': 'DEBUG',
            'class': 'django.utils.log.NullHandler',
        },
        'console':{
            'level': 'INFO',
            'class': 'logging.StreamHandler',
            'formatter': 'verbose'
        },
        'mail_admins': {
            'level': 'ERROR',
            'class': 'django.utils.log.AdminEmailHandler',
            'formatter': 'verbose'
        },
        'logfile': {
            'level': 'INFO',
            'class': 'logging.handlers.WatchedFileHandler',
            'filename': 'E:\NewsApp\NewsUp\greenfield.log',
            'formatter': 'verbose'
        },
    },
    'loggers': {
        'django': {
            'handlers': ['logfile','console'],
            'propagate': True,
            'level': 'ERROR',
        },
        'django.request': {
            'handlers': ['mail_admins','logfile'],
            'level': 'ERROR',
            'propagate': False,
        }
    }
}


CRONJOBS = [
 ('30 6,9,11,15,17,20 * * *', 'NewsUp.cron.my_scheduled_job_Kimono_Hourly'),
 ('30 5,13,16 * * *', 'NewsUp.cron.my_scheduled_job_Kimono_Daily'),
 ('0 6 * * *', 'NewsUp.cron.my_schedule_job_video_daily'),


 ('30 8 * * *', 'NewsUp.cron.my_scheduled_job_TopN'),
 ('58 9 * * *', 'NewsUp.cron.my_scheduled_job_delete_TopN'),
 ('0 10 * * *', 'NewsUp.cron.my_scheduled_job_Top_News'),
 ('0 12 * * *', 'NewsUp.cron.my_scheduled_job_Top_News'),
 ('0 14 * * *', 'NewsUp.cron.my_scheduled_job_hourly'),
 ('0 16 * * *', 'NewsUp.cron.my_scheduled_job_Top_News'),
 ('0 17 * * *', 'NewsUp.cron.my_scheduled_job_hourly'),
 ('58 16 * * *', 'NewsUp.cron.my_scheduled_job_TopN'),
 ('0 18 * * *', 'NewsUp.cron.my_scheduled_job_Top_News'),
 ('30 21 * * *', 'NewsUp.cron.my_scheduled_job_Top_News'),
 ('28 21 * * *', 'NewsUp.cron.my_scheduled_job_delete_TopN'),
 ('58 23 * * *', 'NewsUp.cron.my_scheduled_job_delete_article')

]