import os
import sys

PROJECT_DIR = os.path.dirname(__file__)

BASEDIR = os.path.normpath(
            os.path.dirname(__file__)
          ).replace("\\", "/")

def _p(localpath):
    return os.path.join(BASEDIR, localpath)

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
     ('manuel', 'manueldelarosamorales@gmail.com'),
)

MANAGERS = ADMINS

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': _p('db/innodocente.sqlite'),                     
        'USER': '',                      
        'PASSWORD': '',                  
        'HOST': '',                      
        'PORT': '', 
    }
}


TIME_ZONE = 'Europe/Madrid'


LANGUAGE_CODE = 'ES-es'

SITE_ID = 1

USE_I18N = True

USE_L10N = True

MEDIA_ROOT = _p('media/')

MEDIA_URL = '/media/'

#ADMIN_MEDIA_PREFIX = '/static/admin/'


SECRET_KEY = '67ijp-b11h_u4pd(mr!f(f+2^23i=0837*fibknnxkt_m#(t=6'

TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'app.middleware.AjaxRedirect',

)


ROOT_URLCONF = 'app.urls'
    
TEMPLATE_DIRS = (
    _p('templates'),

)
STATIC_ROOT = _p('static')

STATIC_URL = '/media/static/'

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # Administracion
    'django.contrib.admin',

    # Apps
    'cuestionario',
    'app',
    #'estadisticas',
    'formwizard',
    'registration',
    'tarea',
    'gunicorn', 
    'kombu.transport.django', 
    'djcelery',

)


    

LOGGING = {
    'version': 1,
    'disable_existing_loggers': True,
    'formatters': {
        'simple': {
            'format': '%(levelname)s: %(message)s'
        },
    },
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'class': 'django.utils.log.AdminEmailHandler'
        },
        'console': {
            'level':'INFO',
            'class':'logging.StreamHandler',
            'formatter': 'simple',

        },
        'tareas_info': {
            'level':'INFO',
            'class': 'logging.handlers.RotatingFileHandler',
            'formatter': 'simple',
            'maxBytes': 1024*1024*5, # SIZE : 5 MB
            'filename': _p('logs/tareas_info.log') 

        },
        'tareas_error': {
            'level':'ERROR',
            'class': 'logging.handlers.RotatingFileHandler',
            'formatter': 'simple',
            'maxBytes': 1024*1024*5, # SIZE : 5 MB 
            'filename': _p('logs/tareas_error.log')

        },
    },
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': True,
        },
        'tareas_info': {
            'handlers': ['tareas_info'],
            'level': 'INFO',
            'propagate': True,
        },
        'tareas_error': {
            'handlers': ['tareas_error'],
            'level': 'ERROR',
            'propagate': True,
        }
    }
}

AUTH_PROFILE_MODULE = 'app.Usuario'
LOGIN_REDIRECT_URL = '/'



#____________________________________________


#____________________________________________
#
#
#   Dev [Configuration]
#
#____________________________________________

if os.environ.get('DEVELOPMENT', None):
    from settings_dev import *
