# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os

BASE_DIR = os.path.dirname(os.path.dirname(__file__))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
# you don't say? use is for development only.
SECRET_KEY = 'lv^i97*_qnyil#+p15%uumt*%!*z%4n(q9ov2g18cr4%sc08=t'

DEBUG = None
TEMPLATE_DEBUG = None

ALLOWED_HOSTS = ['*']

TEMPLATE_CONTEXT_PROCESSORS = (
    'django.core.context_processors.i18n',
    'django.contrib.auth.context_processors.auth',
    'django.core.context_processors.request',  # access request var in template
    'core.views.verbose_name_context',
)

WINOSE_MAJOR = 1
WINOSE_MINOR = 4
WINOSE_REVISION = 0

# date time formatting to allow easier sorting in list views
TABLE_DATETIME_FORMAT = '%d. %b %y %H:%M'
TABLE_DATE_FORMAT = '%d. %b %y'

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'verbose': {
            'format': '%(levelname)s %(asctime)s %(module)s %(message)s'
        },
    },
    'handlers': {
        'file': {
            'level': 'DEBUG',
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': BASE_DIR + '/debug.log',
            'formatter': 'verbose',
            'maxBytes': 1024 * 1024 * 5,
            'backupCount': 5,
        },
    },
    'loggers': {
        'django.request': {
            'handlers': ['file'],
            'level': 'DEBUG',
            'propagate': True,
        },
        'wnsq': {
            'handlers': ['file'],
            'level': 'DEBUG',
        }
    },
}

# Application definition

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rest_framework',
    'core',
    'clients',
    'panelists',
    'referencegases',
    'history',
    'bags',
    'projects',
    'samples',
    'users',
    'devices',
    'measurements',
    'report_template',
)

LOGIN_URL = '/users/login/'

AUTH_USER_MODEL = 'users.WinoseUser'

REST_FRAMEWORK = {
    'DEFAULT_RENDERER_CLASSES': (
        'rest_framework.renderers.JSONRenderer',
    ),
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework.authentication.BasicAuthentication',
    ),
    'DEFAULT_PERMISSION_CLASSES': (
        'rest_framework.permissions.IsAuthenticated',
    ),
}

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'request_provider.middleware.RequestProvider',  # access request anywhere, used to get user object on save
)

ROOT_URLCONF = 'wnsq.urls'

WSGI_APPLICATION = 'wnsq.wsgi.application'

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

PROJECT_DIR = os.path.abspath(os.path.dirname(__file__))

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'winose',
        'USER': 'postgres',
        'PASSWORD': 'onde',
        'HOST': 'localhost',
        'PORT': '',
    }
}

LOCALE_PATHS = (
    BASE_DIR + '\\locale',
)

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

LANGUAGE_CODE = 'en'

LANGUAGES = (
    ('en', 'English'),
    ('de', 'German'),
    ('fr', 'French'),
)

# hackish workaround for now, deactive all timezone support and let the
# db system work things out, for postgres this means setting a fixed timezone in
# the db system config files
TIME_ZONE = None
USE_I18N = True
USE_L10N = True
USE_TZ = False

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.6/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = 'static'
# file uploads
MEDIA_ROOT = './docs'
MEDIA_URL = '/docs/'
