# -*- coding: utf-8 -*-
'''
Created on Jan 26, 2012

@author: ymh
'''
import logging
import os

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    # ('Your Name', 'your_email@example.com'),
)

MANAGERS = ADMINS

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

BASE_DIR = os.path.dirname(os.path.abspath(__file__)).rstrip("/") + "/"
BASE_URL = '/~ymh/hdabo/'
WEB_URL = 'http://localhost'

LOCALE_PATHS = ( os.path.join(BASE_DIR, 'locale',), )

# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = os.path.abspath(BASE_DIR + "../static/media/")

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = BASE_URL + "static/media/"

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = os.path.abspath(BASE_DIR + "../static/site/")

# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = BASE_URL + "static/site/"

# URL prefix for admin static files -- CSS, JavaScript and images.
# Make sure to use a trailing slash.
# Examples: "http://foo.com/static/admin/", "/static/admin/".
ADMIN_MEDIA_PREFIX = STATIC_URL + 'admin/'

# Hosts/domain names that are valid for this site; required if DEBUG is False
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
ALLOWED_HOSTS = ['localhost', '127.0.0.1']


GOOGLE_ANALYTICS_CODE = None

LOG_FILE = os.path.abspath(os.path.join(BASE_DIR,"../../run/log/log.txt"))
LOG_LEVEL = logging.DEBUG
LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters' : {
        'simple' : {
            'format': "%(asctime)s - %(levelname)s : %(message)s",
        },
        'semi-verbose': {
            'format': '%(levelname)s %(asctime)s %(module)s %(message)s'
        },                    
    },
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'class': 'django.utils.log.AdminEmailHandler'
        },
        'stream_to_console': {
            'level': LOG_LEVEL,
            'class': 'logging.StreamHandler'
        },
        'file': {
            'level': LOG_LEVEL,
            'class': 'logging.FileHandler',
            'filename': LOG_FILE,
            'formatter': 'semi-verbose',
        },
    }            ,
    'loggers': {
        'hdabo': {
            'handlers': ['file'],
            'level': LOG_LEVEL,
            'propagate': True,
        },
        'hdalab': {
            'handlers': ['file'],
            'level': LOG_LEVEL,
            'propagate': True,
        },
#         'django.db.backends':{
#             'handlers': ['file'],
#             'level': LOG_LEVEL,
#             'propagate': True,
#         },
#         'django.request': {
#             'handlers': ['file'],
#             'level': LOG_LEVEL,
#             'propagate': True,
#         },
    }
}

HAYSTACK_CONNECTIONS = {
    'default': {
        # the elasticsearch_backend is probably temporary
        #'ENGINE': 'hdabo.search.french_whoosh_backend.SearchBackend',
        'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
        'URL': 'http://127.0.0.1:9200/',
        'INDEX_NAME': 'hdabo',
    },
}

DEFAULT_FROM_EMAIL = "do-not-reply@iri-research.org"

RENKAN_PREVIEW_PHANTOMJS_PATH = 'phantomjs'

BROKER_URL = 'sqla+sqlite:///'+os.path.abspath(os.path.join(BASE_DIR,"../../run/celerydb.sqlite"))

#CELERY_EMAIL_BACKEND

ENVELOPE_EMAIL_RECIPIENTS= ['histoiredesarts@culture.gouv.fr']
